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;
}
executeUpdate()执行不了
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答
悬赏问题
- ¥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编程架构设计的方案 有偿