/** * Edits an existing prescription bean. * * @param pres The newly updated prescription bean. * @return A long indicating the ID of the newly updated prescription bean. * @throws DBException */ public long editPrescription(PrescriptionBean pres) throws DBException { Connection conn = null; PreparedStatement ps = null; try { conn = factory.getConnection(); // ps = conn.prepareStatement("UPDATE OVMedication // (VisitID,NDCode,StartDate,EndDate,Dosage,Instructions) VALUES (?,?,?,?,?,?)"); String statement = "UPDATE OVMedication " + "SET VisitID=?, NDCode=?, StartDate=?, EndDate=?, Dosage=?, Instructions=? " + "WHERE ID=?"; ps = conn.prepareStatement(statement); prescriptionLoader.loadParameters(ps, pres); ps.setLong(7, pres.getId()); ps.executeUpdate(); return DBUtil.getLastInsert(conn); } catch (SQLException e) { e.printStackTrace(); throw new DBException(e); } finally { DBUtil.closeConnection(conn, ps); } }