没有错误,但是数据库不更新?????

hhycarot 2005-04-15 02:03:57
问题:执行完下面的语句后,没有抛出异常,但是数据库中的值没有改变,为什么呢?数据库用的oracle,我以前也使用过这种方法,都没有出错过。
... ...
strsql = "update SYS_DMS_TASKS set TASK_Status=? where TASK_ID=?";
try {
//mycon.getMyConnection()返回一个Connection
cStmt = mycon.getMyConnection().prepareCall(strsql);
cStmt.setInt(1, id);
cStmt.setInt(2, status);
flag = cStmt.execute();
}
catch (SQLException e) {
System.out.println(" TaskDAO.changeStatus() " + e.getMessage());
}
... ...
...全文
94 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
全粘架构师 2005-04-15
  • 打赏
  • 举报
回复
catch (Exception e)
光明唧 2005-04-15
  • 打赏
  • 举报
回复
strsql = "update SYS_DMS_TASKS set TASK_Status=? where TASK_ID=?";
cStmt.setInt(1, id);
cStmt.setInt(2, status);
strsql = "update SYS_DMS_TASKS set TASK_Status=? where TASK_ID=?";
cStmt.setInt(1, status);
cStmt.setInt(2, id);
hhycarot 2005-04-15
  • 打赏
  • 举报
回复
在sql plus中没有问题
jFresH_MaN 2005-04-15
  • 打赏
  • 举报
回复
cStmt = mycon.getMyConnection().prepareStatement(strsql);
prepareCall是调用存储过程的时候用的
这里应该是用PreparedStatement类

你这个语句在sql plus里面执行没问题吧?
kingfish 2005-04-15
  • 打赏
  • 举报
回复
cStmt = mycon.getMyConnection().prepareStatement(strsql);
kk2486 2005-04-15
  • 打赏
  • 举报
回复
你这里只会捕捉SQL异常,你把SQLException改成Exception看看

62,634

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧