public void addPatient(Patient p) throws Exception{
Connection conn = Connect.getConnection();
String sql="" +
" insert into medical_record " +
" (病人姓名,性别,年龄,出生日期,家庭电话,移动电话,现住址," +
" 可靠程度,病史叙述者身份及姓名,主诉内容,现病史,记录时间)" +
" values " +
" (?,?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement ptmt = null;
System.out.println(sql.toString());
try {
ptmt = conn.prepareStatement(sql);
ptmt.setString(1,p.getPatient_name());
ptmt.setString(2,p.getSex());
ptmt.setInt(3, p.getAge());
ptmt.setDate(4, new Date(p.getBorn_date().getTime()));
ptmt.setString(5, p.getFamily_phone());
ptmt.setString(6, p.getMobile());
ptmt.setString(7, p.getPresent_address());
ptmt.setString(8, p.getRelible_level());
ptmt.setString(9, p.getDisease_relator());
ptmt.setString(10, p.getChief_complaints());
ptmt.setString(11, p.getPresent_illness());
ptmt.setDate(12,new Date(p.getRecord_time().getTime()));
int a = ptmt.executeUpdate();
if(a>0){
System.out.println("添加成功。");
}else {
System.out.println("添加失败。");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(ptmt!=null){
ptmt.close();
}if (conn!=null) {
conn.close();
}
}
}
tanhouyusheng
mjka5632