JSP、eclipse中更新错误
- 无法发出数据操作 语句与executeQuery()。
更新JAVA代码
MultiDBManager db8=new MultiDBManager(uif);
String updateString = "UPDATE pklrsc SET pr_prod_rate="+rate+" , pr_ln_cst="+cost+" WHERE pr_rsc_cde= "+component+" ";
db8.execSQL(updateString);
.java文件代码
public ResultSet execSQL(String sql) throws SQLException {
System.out.println("execSQL");
return super.execSQL(processQuery(sql));
}
private String processQuery(String sql){
System.out.println("processQuery");
return mdb.getCacheDB().procSQL(sql, false);
}
错误消息
value i: 1
component: ACODE0001
rate: 2.00
cost: 261.22
execSQL
processQuery
Execute = UPDATE c66_p30_BIS.pklrsc SET pr_prod_rate=2.00 , pr_ln_cst=261.22 WHERE pr_rsc_cde= ACODE0001
Nov 4, 2010 4:54:49 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.Statement.checkForDml(Statement.java:398)
- Can not issue data manipulation
statements with executeQuery().
UPDATING JAVA CODE
MultiDBManager db8=new MultiDBManager(uif);
String updateString = "UPDATE pklrsc SET pr_prod_rate="+rate+" , pr_ln_cst="+cost+" WHERE pr_rsc_cde= "+component+" ";
db8.execSQL(updateString);
.java FILE CODE
public ResultSet execSQL(String sql) throws SQLException {
System.out.println("execSQL");
return super.execSQL(processQuery(sql));
}
private String processQuery(String sql){
System.out.println("processQuery");
return mdb.getCacheDB().procSQL(sql, false);
}
ERROR MESSAGE
value i: 1
component: ACODE0001
rate: 2.00
cost: 261.22
execSQL
processQuery
Execute = UPDATE c66_p30_BIS.pklrsc SET pr_prod_rate=2.00 , pr_ln_cst=261.22 WHERE pr_rsc_cde= ACODE0001
Nov 4, 2010 4:54:49 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.Statement.checkForDml(Statement.java:398)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
INSERT
/UPDATE
/DELETE
时必须调用executeUpdate()
,而不是executeQuery()
另请注意,不鼓励在 JSP(一种视图技术)中使用代码。
You must call
executeUpdate()
when usingINSERT
/UPDATE
/DELETE
, rather thanexecuteQuery()
Also note that using code in JSP, which is a view technology, is not encouraged.
您正在使用隐藏的
executeQuery
调用来更新数据库中的值。这是不允许的(参见例外)。这个方法调用实际上给你带来了麻烦:
找到一个替代方法来发送更新语句(实际上我不知道你在这里使用什么API)
You're using a hidden
executeQuery
call to update values in the database. That's not allowed (see exception).This method call actually causes your trouble:
Find an alternative to send update statements (Actually I don't know what API you're using here)