コード例 #1
0
  public DataBaseManagement(String driver, String dbURL) {

    try {
      this.dbURL = dbURL;
      Class.forName(driver).newInstance();
      conn = DriverManager.getConnection(dbURL);

    } catch (InstantiationException
        | IllegalAccessException
        | ClassNotFoundException
        | SQLException e) {
      // TODO Auto-generated catch block

      if (e instanceof SQLException) {

        SQLException sqle = (SQLException) e;
        if (sqle.getSQLState().equals("XJ040")) {

          sqle = sqle.getNextException();
          if (sqle.getSQLState().equals("XSDB6")) {

            logger.error(sqle.getMessage() + " Please shutdown that other instance of Derby.");
          }
        }
      } else {

        CustomException.errorPrint(e);
      }
    }
  }
コード例 #2
0
 @ExceptionHandler({
   InvalidEntityConstraintsException.class,
   InvalidIdException.class,
   EntityAlreadyExistsException.class,
   AssociationAlreadyExistsException.class
 })
 public ResponseEntity<?> handleBadRequests(CustomException e) {
   return new ResponseEntity<>(e.getErrorMessage(), HttpStatus.BAD_REQUEST);
 }
コード例 #3
0
  @Override
  public void run() {
    // TODO Auto-generated method stub

    try {
      dropAllTables();
      createTables();
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      CustomException.errorPrint(e);
    }
  }
コード例 #4
0
 @ExceptionHandler({EntityNotFoundException.class, AssociationNotFoundException.class})
 public ResponseEntity<?> handleNotFounds(CustomException e) {
   return new ResponseEntity<>(e.getErrorMessage(), HttpStatus.NOT_FOUND);
 }