public void deleteServicePrice(ServicePrice servicePrice) { try { PreparedStatement preparedStatement = getConnection() .prepareStatement( "DELETE FROM \"service_price\" where \"service_id\" = ? AND \"date\" = ?"); preparedStatement.setInt(1, servicePrice.getServiceId()); preparedStatement.setDate(2, Date.valueOf(servicePrice.getDate())); preparedStatement.executeUpdate(); } catch (SQLException ex) { ex.printStackTrace(); throw new DAOException(); } }
public void saveServicePrice(ServicePrice servicePrice) { try { PreparedStatement preparedStatement = getConnection() .prepareStatement( "INSERT INTO \"service_price\" (\"service_id\", \"date\", \"price\") VALUES(?, ?, ?)"); preparedStatement.setInt(1, servicePrice.getServiceId()); preparedStatement.setDate(2, Date.valueOf(servicePrice.getDate())); preparedStatement.setBigDecimal(3, servicePrice.getPrice()); preparedStatement.executeUpdate(); } catch (SQLException ex) { ex.printStackTrace(); throw new DAOException(); } }