Topic: 用PreparedStatement.executeQuery()时候报异常 |
Print this page |
1.用PreparedStatement.executeQuery()时候报异常 | Copy to clipboard |
Posted by: micsolaris Posted on: 2008-11-10 21:26
<---------------------------------------------------------------------> Exception in thread "main" java.sql.SQLException: Microsoft ODBC Microsoft Access Driver 参数不足,期待是 1。 at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source) at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Unknown Source) at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeQuery(Unknown Source) at com.ricky.test.StatementTest.doPreparedStatement(StatementTest.java:62) at com.ricky.test.StatementTest.main(StatementTest.java:19) 请问下如何解决啊 |
2.Re:用PreparedStatement.executeQuery()时候报异常 [Re: micsolaris] | Copy to clipboard |
Posted by: JiafanZhou Posted on: 2008-11-14 19:13 Using PreparedStatement object can send parameterized SQL statement to the database. I am not sure what will happen if you create a PreparedStatement without any parameters. It is important to note that PreparedStatenment will require the driver to support precompilation. Some drivers may not support precompilation. In this case, it does affect which methods throw certain SQLException object. I am currently working on a Linux machine, thus I cannot retest your program at the moment. I do have a windows machine at home, and I will be likely to test your code at the weekend. Thanks, Jiafan |
3.Re:用PreparedStatement.executeQuery()时候报异常 [Re: micsolaris] | Copy to clipboard |
Posted by: micsolaris Posted on: 2008-11-14 22:48 谢谢JiafanZhou 我发现我错在哪里了,我把 String sql = "SELECT authid,lastname,fristname FROM authors ORDER BY authid";中的firstname写错了,所以出现了异常。 |
4.Re:用PreparedStatement.executeQuery()时候报异常 [Re: micsolaris] | Copy to clipboard |
Posted by: JiafanZhou Posted on: 2008-11-15 00:07 Cool... this is exactly why Gavin invented the Hibernate.!! Jiafan |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |