Esempio n. 1
0
 /**
  * Returns the Connection for the HikariCP Database
  *
  * @return The Connection
  */
 @Override
 protected final Connection getConnection() {
   StorageAction storageAction =
       new StorageAction(
           StorageAction.Type.SQL_GETCONNECTION,
           this.hostName,
           String.valueOf(this.port),
           this.name,
           this.user);
   Connection c = null;
   try {
     c = this.dataSource.getConnection();
     storageAction.setSuccess(true);
   } catch (SQLException e) {
     e.printStackTrace();
     this.jLogger.log(
         ChatColor.RED + "Failed to connect to the SQL Database using following credentials:",
         JLogger.LogLevel.MINIMAL);
     this.jLogger.log(ChatColor.RED + "HostName: " + this.hostName, JLogger.LogLevel.MINIMAL);
     this.jLogger.log(ChatColor.RED + "Port: " + this.port, JLogger.LogLevel.MINIMAL);
     this.jLogger.log(ChatColor.RED + "Database: " + this.name, JLogger.LogLevel.MINIMAL);
     this.jLogger.log(ChatColor.RED + "User: " + this.user, JLogger.LogLevel.MINIMAL);
     storageAction.setSuccess(false);
   }
   this.actions.add(storageAction);
   return c;
 }
Esempio n. 2
0
 @Override
 public final void disconnect() {
   StorageAction storageAction =
       new StorageAction(
           StorageAction.Type.SQL_DISCONNECT,
           this.hostName,
           String.valueOf(this.port),
           this.name,
           this.user);
   try {
     this.dataSource.close();
     storageAction.setSuccess(true);
   } catch (Exception e) {
     e.printStackTrace();
     storageAction.setSuccess(false);
   }
   this.actions.add(storageAction);
 }