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

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 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn