java程序出现问题:java.sql.SQLException: ORA-01008: 并非所有变量都已绑定

异常提示是 并非所有变量都已绑定,实际上从sql语句上看是没有问题,直接使用在数据库也是有效的,那么他为什么会报ORA-01008: 并非所有变量都已绑定,这个这个问题一般出现在sql语句,因为程序写的sql语句可能出现所查询没有的字段,而此处sql语句没有错误,出问题的地方是preparedStatemnt.executeUpdate(sql)这条语句,这是使用PreparedStatement对象来执行sql语句,他的作用是防止客户端注入问题,他调用的是preparedStatement = connection.prepareStatement(sql,new String[]{"FID"});来执行sql语句,所以在下面的preparedStatemnt.executeUpdate(sql),就不要在放参数了,改成preparedStatemnt.executeUpdate(),程序问题解决。

猜你喜欢

转载自blog.csdn.net/try_and_do/article/details/81911132