How do I use a PreparedStatement
to pass a string in a where
clause?
I have tried following lines of code:
String sql = "select pass from lbdb_user WHERE username = ? collate latin1_bin";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1,"\""+username+"\"" );
It throws the following mysql exception:
You have an error in your SQL syntax;