Package org.adbcj

Examples of org.adbcj.DbException


   * @throws Exception
   */
  public Throwable handleException(AbstractMySqlConnection connection, Throwable cause) throws Exception {
    logger.debug("Caught exception: ", cause);

    DbException dbException = DbException.wrap(connection, cause);
    if (connection != null) {
      DefaultDbFuture<Connection> connectFuture = connection.getConnectFuture();
      if (!connectFuture.isDone()) {
        connectFuture.setException(dbException);
        return null;
View Full Code Here


    this.properties.put(PASSWORD, password);
  }

  public DbFuture<Connection> connect() throws DbException {
    if (isClosed()) {
      throw new DbException("This connection manager is closed");
    }
    final DbFutureConcurrentProxy<Connection> future = new DbFutureConcurrentProxy<Connection>();
    Future<Connection> executorFuture = executorService.submit(new Callable<Connection>() {
      public Connection call() throws Exception {
        try {
          java.sql.Connection jdbcConnection = DriverManager.getConnection(jdbcUrl, properties);
          JdbcConnection connection = new JdbcConnection(JdbcConnectionManager.this, jdbcConnection);
          synchronized (lock) {
            if (isClosed()) {
              connection.close(true);
              future.setException(new DbException("Connection manager closed"));
            } else {
              connections.add(connection);
              future.setValue(connection);
            }
          }
          return connection;
        } catch (SQLException e) {
          future.setException(new DbException(e));
          e.printStackTrace();
          throw e;
        } finally {
          future.setDone();
        }
View Full Code Here

      }
      String schema = uri.getPath().substring(1);

      return new MysqlConnectionManager(host, port, username, password, schema, properties);
    } catch (URISyntaxException e) {
      throw new DbException(e);
    }
  }
View Full Code Here

      String jdbcUrl = uri.toString();

      return new JdbcConnectionManager(jdbcUrl, username, password, properties);
    } catch (URISyntaxException e) {
      throw new DbException(e);
    }
  }
View Full Code Here

 
  public boolean isClosed() {
    try {
      return closeFuture != null || jdbcConnection.isClosed();
    } catch (SQLException e) {
      throw new DbException(this, e);
    }
  }
View Full Code Here

  public void doClose() {
    connectionManager.removeConnection(this);

    // TODO Make a DbSessionClosedException and use here
    DbException closedException = new DbException("Connection closed");
    if (!getConnectFuture().isDone() ) {
      getConnectFuture().setException(closedException);
    }
    errorPendingRequests(closedException);
    synchronized (this) {
View Full Code Here

    return closeFuture != null;
  }

  public DbFuture<Connection> connect() {
    if (isClosed()) {
      throw new DbException("Connection manager closed");
    }
    logger.debug("Starting connection");

    return createConnectionFuture();
  }
View Full Code Here

      if (port < 0) {
        port = DEFAULT_PORT;
      }
      String path = uri.getPath().trim();
      if (path.length() == 0 || "/".equals(path)) {
        throw new DbException("You must specific a database in the URL path");
      }
      String schema = path.substring(1);

      return new MysqlConnectionManager(host, port, username, password, schema, properties);
    } catch (URISyntaxException e) {
      throw new DbException(e);
    }
  }
View Full Code Here


  @Override
  public DbFuture<org.adbcj.Connection> connect() {
    if (isClosed()) {
      throw new DbException("Connection manager is closed");
    }
    final ChannelFuture channelFuture = bootstrap.connect();
    return new PostgresqlConnectFuture(channelFuture);
  }
View Full Code Here

      if (isDone() && set) {
        return value;
      }
      return future.get();
    } catch (ExecutionException e) {
      throw new DbException(e);
    }
  }
View Full Code Here

TOP

Related Classes of org.adbcj.DbException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.