// 根据id查找病人 public Patient queryOne(int id) { Patient p = new Patient(); String sql = "select id,name,sex,doctor,section,entertime,room,bed,cation from patient where id=" + id; PreparedStatement pst = null; Connection conn = null; ResultSet rs = null; try { conn = DBHelp.getConnection(); pst = conn.prepareStatement(sql); rs = pst.executeQuery(); while (rs.next()) { p.setId(rs.getInt(1)); p.setName(rs.getString(2)); p.setSex(rs.getString(3)); p.setDoctor(rs.getString(4)); p.setSection(rs.getString(5)); p.setEnetertime(rs.getDate(6)); p.setRoom(rs.getString(7)); p.setBed(rs.getShort(8)); p.setCation(rs.getString(9)); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { DBHelp.closeConn(rs); DBHelp.closeConn(pst); DBHelp.closeConn(conn); } return p; }