@Override public DrugGroup update(DrugGroup object) { boolean result = true; try { preparedStatement = connection.prepareStatement( "UPDATE DRUGGROUP SET " + "DrugGroupName = ? WHERE DrugGroupID = ?"); preparedStatement.setString(1, object.getDrugGroupName()); preparedStatement.setString(2, object.getDrugGroupID()); result = preparedStatement.execute(); } catch (SQLException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } return result ? object : null; }
@Override public DrugGroup save(DrugGroup object) { boolean result = true; try { preparedStatement = connection.prepareStatement( "INSERT INTO DRUGGROUP(DrugGroupID, DrugGroupName) VALUES(?,?)"); preparedStatement.setString(1, object.getDrugGroupID()); preparedStatement.setString(2, object.getDrugGroupName()); result = preparedStatement.execute(); } catch (SQLException e) { } return result ? object : null; }
@Override public DrugGroup get(String id) { DrugGroup drugGroup = null; try { preparedStatement = connection.prepareStatement("SELECT * FROM DRUGGROUP WHERE DRUGGROUP.DrugGroupID = ?"); preparedStatement.setString(1, id); resultSet = preparedStatement.executeQuery(); if (resultSet.next()) { drugGroup = new DrugGroup(); drugGroup.setDrugGroupID(resultSet.getString("DrugGroupID")); drugGroup.setDrugGroupName((resultSet.getString("DrugGroupName"))); } } catch (SQLException e) { } return drugGroup; }