Problem with Java/MySQL query...
I seem to be getting an error
Code :
ERROR: 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 '' at line 1
Code :
try{
con = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");
PreparedStatement pst = con.prepareStatement("INSERT INTO accounts(username, accessLevel, password) VALUES (?,?,AES_ENCRYPT=('"+passwordE+"','enigma')");
pst.setString(1, jTextField1.getText());
pst.setInt(2, accessLevel);
pst.executeUpdate();
con.close();
System.out.println("Disconnected from database");
new Menu().setVisible(true);
this.dispose();
} catch (SQLException e) {System.err.println("ERROR: " + e.getMessage()); }
}
Re: Problem with Java/MySQL query...
Your SQL syntax is incorrect. Make sure the SQL you are passing to the PreparedStatement is correct SQL syntax (for example, AES_ENCRYPT is typically called without the equals sign - should also make use of the PreparedStatement and rather than string concatenate, use the '?' for the encryption variables)
Re: Problem with Java/MySQL query...
Moved thread to - JDBC & Databases