COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0100E 参数数目错误。 SQLSTATE=07001
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2Statement.execute2(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2Statement.executeQuery(Unknown Source)
at JDBC.Test7_3.Test7_3.main(Test7_3.java:52)
这个因为什么?我找好久都不知道哪里出错了。不贴代码了,太长了!!
我用的是PreparedStatement。
sqlUpdate = "update accounts set password=?,name=?,sex=?,money=? where number=?";
psmt = conn.prepareStatement(sqlUpdate);
psmt.setString(1, password);
psmt.setString(2, name);
psmt.setInt(3, Integer.parseInt(sex));
psmt.setDouble(4, Double.parseDouble(String.valueOf(money)));
psmt.setString(5, number);returnValue = psmt.executeUpdate(sqlUpdate);
System.out.println("修改:returnValue:" + returnValue);
if (returnValue >= 0) {
System.out.println("修改数据成功!");
}这不是一致的嘛?
at JDBC.Test7_3.Test7_3.main(Test7_3.java:52)
你确定是你上面那些代码么
Test7_3.java中的52行,好像在执行一个executeQuery操作啊
而你在程序中偏要查6个自段 就出错了。。检查检查 数据表字段 与 你程序中所查的是否一致
这个错误 是因为参数数目不对导致的
但看你的代码的确没看出什么问题来
不懂,建议LZ再一步步检查下吧,应是某个地方大意了、、、
psmt = conn.prepareStatement(sqlUpdate);
psmt.setString(0, password);
psmt.setString(1, name);
psmt.setInt(2, Integer.parseInt(sex));
psmt.setDouble(3, Double.parseDouble(String.valueOf(money)));
psmt.setString(4, number);
改为 rs = psmt.executeQuery();