coffee520451 2015-12-23 09:34 采纳率: 0%
浏览 4085

executeUpdate()执行不了

jdbc连接数据库,执行到executeUpdate()时就一直没反应,试过输出语句,在此前可以输出,此后就没反应了,代码如下:
public static boolean insert(int id, String pwd, String name,
String phone, String email){
boolean flag = false;
Connection conn = null;
PreparedStatement prep = null;
try {
conn = DriverManager.getConnection(url, dbUser, dbPassword);
String sql = "insert into user_001(id,password,name,phone,email) " +
"values(?,?,?,?,?)";
prep = conn.prepareStatement(sql);
prep.setInt(1, id);
prep.setString(2, pwd);
prep.setString(3, name);
prep.setString(4, phone);
prep.setString(5, email);
System.out.println("before n");
int n = prep.executeUpdate();
System.out.println("n:" + n);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(prep != null){
try {
prep.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(conn != null){
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return flag;
}

  • 写回答

3条回答

  • sinat_31535993 2015-12-23 09:57
    关注

    驱动加载了吗?抛异常了吗?

    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿