The problem is to write the correct line with the prepared statementom ..

Where is the syntax error?

Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection(URL,USER_NAME,PASSWORD); String checkingUser = "SELECT nick_name FROM users WHERE nick_name=? AND password=? AND users.email=?"; PreparedStatement preparedStatement = connection.prepareStatement(checkingUser); System.out.println("Before 1"); preparedStatement.setString(1,loginData[0]); System.out.println("Before 2"); preparedStatement.setString(2,loginData[1]); System.out.println("Before 3"); preparedStatement.setString(3,loginData[2]); preparedStatement.execute(); com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to user near '?, password=?, users.email=?' at line 1 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? AND password=? AND users.email=?' at line 1 // перезагрузил сервак, получил данную ошибку. Что тут нетак не понимаю.. Пример кода в другой части програмы, который работает. String e = "UPDATE coupon SET start_date = ? , end_date = ? , amount = ? , price = ? , image = ? WHERE id = ?"; 

Problem with and ??

 SELECT nick_name FROM users WHERE nick_name="****" AND password="*****" AND users.email="******"; 

This design works in the usual database query. But not with the Prepared Statement.

Receive alerts from IDEA SQL Dialect is not configured! What and how do I set up?

  • What is users.email and why is it not just an email ? - post_zeew
  • SELECT nick_name FROM users WHERE nick_name = " " AND password = " " AND users.email = "***"; This is what IDEA generated in DATABASE, if you work directly with MySql then there is no problem with such a request. As soon as I use it in the string with the first statement, I get an error in the syntax. - Maks.Burkov
  • I do not understand how it turns out that AND is in your query, and when MySQL swears at the error, it says that there are commas - Mike
  • I don't understand either ... - Maks.Burkov
  • As far as I understand, an error with binding. I have never worked with PS directly, but perhaps there is either a counting from scratch, or for unnumbered / unnamed parameters, the binding is done differently. - etki

0