What's wrong with my statement? String prdID = "a111"; String sql = "Select * " + "from Prd_Cat " + "where PID = " + prdID; rs = stmt.executeQuery(sql); My database connection is no problem, I can execute other sql statements. However, when I executed the above statment , an error message is generated: --------------------- java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6031) at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6188) at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2494) at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:334) at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:249) at ProductDesptServlet.doGet(ProductDesptServlet.java:68) .............................. What does the error message mean?
Balaji C
Greenhorn
Joined: Mar 05, 2002
Posts: 1
posted
0
Some time we might have missed space between "select *" and "from Prd_Cat" since these two are typed in diff lines. So just print the query in the out.println(sql). This will print the query in either in the page or in the html. Copy the query and paste the same in the SQL * Plus. There it will exactly point out the place where you did the mistake. I could not able to answer this question because I did not have any infornation about your table. Hope this helps [ March 05, 2002: Message edited by: Balaji C ]
Regards,<br />Balaji. C
Stelian Iancu
Greenhorn
Joined: Feb 20, 2002
Posts: 21
posted
0
Try using a PreparedStatement instead: String sql = "Select * " + "from Prd_Cat " + "where PID = ?"; PreparedStatement ps = conn.prepareStatement(sql); ps.setString(1, prID); rs = ps.executeQuery(); And see what happens.
--<br />Linux registered user 287835<br /> <br />Be different. Think.