Ejemplo n.º 1
0
 public Integer add(WheelsBCD entity) {
   Integer generatedId = null;
   ResultSet resultSet = null;
   Connection connection = null;
   PreparedStatement preparedStatement = null;
   if (checkEntity(entity)) {
     try {
       connection = connectionPool.getConnection();
       preparedStatement =
           (PreparedStatement)
               connection.prepareStatement(addRequest, PreparedStatement.RETURN_GENERATED_KEYS);
       preparedStatement.setString(1, entity.getValue());
       preparedStatement.execute();
       resultSet = preparedStatement.getGeneratedKeys();
       if (resultSet.next()) {
         generatedId = resultSet.getInt(1);
       }
     } catch (SQLException ex) {
       generatedId = null;
     } finally {
       closeAll(resultSet, preparedStatement, connection);
     }
   }
   return generatedId;
 }
Ejemplo n.º 2
0
 private boolean checkEntity(WheelsBCD entity) {
   boolean checked = true;
   if (entity == null || entity.getValue() == null) {
     checked = false;
   }
   return checked;
 }