62,621
社区成员
发帖
与我相关
我的任务
分享public boolean doCreate(Person per) throws Exception {
boolean flag = false;
PreparedStatement psmt = null;
String sql = "INSERT INTO Person(pid,name,age,address,birthday)"
+ " VALUES (myseq.nextval,?,?,?,?)";
System.out.print(sql);
try {
psmt = this.con.prepareStatement(sql);
psmt.setString(1, per.getName());
psmt.setInt(2, per.getAge());
psmt.setString(3, per.getAddress());
psmt.setDate(4, new java.sql.Date(per.getBirthday().getTime()));
int len = psmt.executeUpdate();
if (len > 0) {
flag = true;
}
} catch (Exception e) {
throw e;
} finally {
try {
psmt.close();
} catch (Exception e) {
throw e;
}
}
return flag;if(pstm!=null){
psmt.close();
}