Ejemplo n.º 1
0
 @Override
 public int addExpense(Expense expense) throws SQLException {
   insertStatement = connection.prepareStatement(INSERT);
   insertStatement.clearParameters();
   insertStatement.setInt(1, expense.getNum());
   insertStatement.setDate(2, expense.getPaydate());
   insertStatement.setInt(3, expense.getReceiver());
   insertStatement.setInt(4, expense.getValue());
   int result = insertStatement.executeUpdate();
   return result;
 }
Ejemplo n.º 2
0
 @Override
 public int updateExpense(int num, Expense expense) throws SQLException {
   updateByNumStatement = connection.prepareStatement(UPDATE_BY_NUM);
   updateByNumStatement.clearParameters();
   updateByNumStatement.setDate(1, expense.getPaydate());
   updateByNumStatement.setInt(2, expense.getReceiver());
   updateByNumStatement.setInt(3, expense.getValue());
   updateByNumStatement.setInt(4, num);
   int result = updateByNumStatement.executeUpdate();
   return result;
 }