I have a servlet which supposed to update my Access table. My table contains 3 fields : account,password,name. I ran below snippets of my servlet and compiler gave me SQL syntax error. String INSERT ="INSERT INTO login-table (login_id ,password ,name) " + "VALUES (?, ?, ?)"; PreparedStatement pstmt = null; pstmt = con.prepareStatement(INSERT); pstmt.setString(1, account); pstmt.setString(2,password); pstmt.setString(3,name);
I also tried this SQL format . stmt.executeUpdate("INSERT INTO login-table " + " (login_id ,password ,name ) " + "VALUES " + "('" + account + "', '" + password + "', '" + name + "');"); Also gave me SQL syntax error Pls help
SCJP 2 1.4
Joined: Feb 28, 2003
Could you paste the exact SQLException tht you get when executing the first statement? On what line does the error occur? What driver are you using / could you paste entire servlet?
Joined: May 05, 2003
I've tested the JDBC-ODBC connection, its working fine , its just the SQL command....(i thk) 2003-06-17 10:47:48 - PoolTcpConnector: Starting Ajp12ConnectionHandler on 8007 SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT I NTO statement.