Here is my code guys, what am I doing wrong (I am forced to use a regular Statement as opposed to the PreparedStatement class so that I can use mySQL’s AES_ENCRYPT/DECRYPT methods):
DDL
s.executeUpdate("CREATE TABLE login ("+"user_Name CHAR(50) NOT NULL,"+"PRIMARY KEY(user_Name),"+"pass_Word CHAR(50)NOT NULL, cust_ID CHAR(10))");
DML
public static void insertLoginData(String user_Name, String pass_Word, String cust_ID)throws IOException, SQLException, NoSuchAlgorithmException, InvalidKeyException
{
. . .
String insert="INSERT INTO login(user_Name, pass_Word, cust_ID)"
+ " VALUES("+user_Name+",AES_ENCRYPT('text',"+pass_Word+"),"+cust_ID+")";
s.executeUpdate(insert);
You probably need single quotes around the column values like this:
On a side note: Someone will eventually point out that this code is subject to SQL injection attack.