executeUpdate()下面的语句死活不执行

怒吼的皮皮 2013-11-28 10:44:39
代码执行到pstmt.executeUpdate();往下就不执行了,即使写错误代码也不检查,求高手支招呀!~
public static void addChildCategory(int pid,String name,String descr) {
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs = null;
try {
conn = DB.getConn();
conn.setAutoCommit(false);
rs=DB.executeQuery(conn, "select * from category where id ="+pid);
rs.next();
int parentGrade=rs.getInt("grade");
String sql = "insert into category values(null,?,?,?,?,?)";
pstmt=DB.getPStmt(conn, sql);
pstmt.setInt(1, pid);
pstmt.setString(2, name);
pstmt.setString(3, descr);
pstmt.setInt(4, 0);
pstmt.setInt(5, parentGrade+1);
pstmt.executeUpdate();
DB.executeQuery(conn, "update category set isleaf = 1 where id =16");
conn.commit();
} catch (Exception e) {
e.printStackTrace();
}
finally{
DB.closeRs(rs);
DB.closeStmt(pstmt);
DB.closeConn(conn);
}

}
...全文
314 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
接个分吧。。。
怒吼的皮皮 2013-11-29
  • 打赏
  • 举报
回复
解决了,改成pstmt.executeUpdate( "update category set isleaf = 1 where id =16");就可以了,谢谢大家!
郑燕辉 2013-11-29
  • 打赏
  • 举报
回复
好像表被锁了
南猿北蛰 2013-11-29
  • 打赏
  • 举报
回复
String sql = "insert into category values(null,?,?,?,?,?)"; 这里是否应该把具体字段写清楚,后面插入字段类型看是否一一对应。
zark 2013-11-29
  • 打赏
  • 举报
回复
DB.executeQuery(conn, "update category set isleaf = 1 where id =16"); executeQuery 不应该是用来执行查询语句的么???

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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