Пример #1
0
  @Override
  public void setReadOnly(boolean readOnly) throws SQLException {
    checkState();

    conn.setReadOnly(readOnly);
    holder.setUnderlyingReadOnly(readOnly);
  }
Пример #2
0
  @Override
  public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
      throws SQLException {
    checkState();

    PreparedStatementHolder stmtHolder = null;
    PreparedStatementKey key =
        new PreparedStatementKey(
            sql, getCatalog(), MethodType.Precall_3, resultSetType, resultSetConcurrency);

    boolean poolPreparedStatements = holder.isPoolPreparedStatements();

    if (poolPreparedStatements) {
      stmtHolder = holder.getStatementPool().get(key);
    }

    if (stmtHolder == null) {
      try {
        stmtHolder =
            new PreparedStatementHolder(
                key, conn.prepareCall(sql, resultSetType, resultSetConcurrency));
        holder.getDataSource().incrementPreparedStatementCount();
      } catch (SQLException ex) {
        handleException(ex);
      }
    }

    initStatement(stmtHolder);

    DruidPooledCallableStatement rtnVal = new DruidPooledCallableStatement(this, stmtHolder);
    holder.addTrace(rtnVal);

    return rtnVal;
  }
Пример #3
0
  @Override
  public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
    checkState();

    PreparedStatementKey key =
        new PreparedStatementKey(sql, getCatalog(), MethodType.M6, autoGeneratedKeys);
    PreparedStatementHolder stmtHolder = null;

    boolean poolPreparedStatements = holder.isPoolPreparedStatements();

    if (poolPreparedStatements) {
      stmtHolder = holder.getStatementPool().get(key);
    }

    if (stmtHolder == null) {
      try {
        stmtHolder =
            new PreparedStatementHolder(key, conn.prepareStatement(sql, autoGeneratedKeys));
        holder.getDataSource().incrementPreparedStatementCount();
      } catch (SQLException ex) {
        handleException(ex);
      }
    }

    initStatement(stmtHolder);

    DruidPooledPreparedStatement rtnVal = new DruidPooledPreparedStatement(this, stmtHolder);

    holder.addTrace(rtnVal);

    return rtnVal;
  }
Пример #4
0
  @Override
  public void setHoldability(int holdability) throws SQLException {
    checkState();

    conn.setHoldability(holdability);
    holder.setUnderlyingHoldability(holdability);
  }
Пример #5
0
  @Override
  public void setTransactionIsolation(int level) throws SQLException {
    checkState();

    conn.setTransactionIsolation(level);
    holder.setUnderlyingTransactionIsolation(level);
  }
Пример #6
0
 @Override
 public void clearWarnings() throws SQLException {
   checkState();
   try {
     conn.clearWarnings();
   } catch (SQLException ex) {
     handleException(ex);
   }
 }
Пример #7
0
 @Override
 public void releaseSavepoint(Savepoint savepoint) throws SQLException {
   checkState();
   try {
     conn.releaseSavepoint(savepoint);
   } catch (SQLException ex) {
     handleException(ex);
   }
 }
Пример #8
0
  @Override
  public void setCatalog(String catalog) throws SQLException {
    checkState();

    try {
      conn.setCatalog(catalog);
    } catch (SQLException ex) {
      handleException(ex);
    }
  }
Пример #9
0
  @Override
  public Savepoint setSavepoint(String name) throws SQLException {
    checkState();

    try {
      return conn.setSavepoint(name);
    } catch (SQLException ex) {
      handleException(ex);
      return null; // never arrive
    }
  }
Пример #10
0
  @Override
  public Clob createClob() throws SQLException {
    checkState();

    try {
      return conn.createClob();
    } catch (SQLException ex) {
      handleException(ex);
      return null; // never arrive
    }
  }
Пример #11
0
  @Override
  public Savepoint setSavepoint() throws SQLException {
    checkState();

    try {
      return conn.setSavepoint();
    } catch (SQLException ex) {
      handleException(ex);
      return null;
    }
  }
Пример #12
0
  @Override
  public void setAutoCommit(boolean autoCommit) throws SQLException {
    checkState();

    try {
      conn.setAutoCommit(autoCommit);
      holder.setUnderlyingAutoCommit(autoCommit);
    } catch (SQLException ex) {
      handleException(ex);
    }
  }
Пример #13
0
  public void test_checkOpen_error() throws Exception {
    DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);

    conn.close();
    {
      Exception error = null;
      try {
        conn.checkState();
      } catch (SQLException ex) {
        error = ex;
      }
      Assert.assertNotNull(error);
    }
  }
Пример #14
0
  @Override
  public void setHoldability(int holdability) throws SQLException {
    checkState();

    boolean useLocalSessionState = holder.getDataSource().isUseLocalSessionState();
    if (useLocalSessionState) {
      if (holdability == holder.getUnderlyingHoldability()) {
        return;
      }
    }

    conn.setHoldability(holdability);
    holder.setUnderlyingHoldability(holdability);
  }
Пример #15
0
  @Override
  public void commit() throws SQLException {
    checkState();

    DruidAbstractDataSource dataSource = holder.getDataSource();
    dataSource.incrementCommitCount();

    try {
      conn.commit();
    } catch (SQLException ex) {
      handleException(ex);
    } finally {
      handleEndTransaction(dataSource, null);
    }
  }
Пример #16
0
  @Override
  public Statement createStatement() throws SQLException {
    checkState();

    Statement stmt = null;
    try {
      stmt = conn.createStatement();
    } catch (SQLException ex) {
      handleException(ex);
    }

    holder.getDataSource().initStatement(this, stmt);

    DruidPooledStatement poolableStatement = new DruidPooledStatement(this, stmt);
    holder.addTrace(poolableStatement);

    return poolableStatement;
  }
Пример #17
0
  @Override
  public void setTransactionIsolation(int level) throws SQLException {
    checkState();

    boolean useLocalSessionState = holder.getDataSource().isUseLocalSessionState();
    if (useLocalSessionState) {
      if (level == holder.getUnderlyingTransactionIsolation()) {
        return;
      }
    }

    try {
      conn.setTransactionIsolation(level);
    } catch (SQLException ex) {
      handleException(ex);
    }
    holder.setUnderlyingTransactionIsolation(level);
  }
Пример #18
0
  @Override
  public void setAutoCommit(boolean autoCommit) throws SQLException {
    checkState();

    boolean useLocalSessionState = holder.getDataSource().isUseLocalSessionState();

    if (useLocalSessionState) {
      if (autoCommit == holder.isUnderlyingAutoCommit()) {
        return;
      }
    }

    try {
      conn.setAutoCommit(autoCommit);
      holder.setUnderlyingAutoCommit(autoCommit);
    } catch (SQLException ex) {
      handleException(ex);
    }
  }
Пример #19
0
  @Override
  public void setReadOnly(boolean readOnly) throws SQLException {
    checkState();

    boolean useLocalSessionState = holder.getDataSource().isUseLocalSessionState();
    if (useLocalSessionState) {
      if (readOnly == holder.isUnderlyingReadOnly()) {
        return;
      }
    }

    try {
      conn.setReadOnly(readOnly);
    } catch (SQLException ex) {
      handleException(ex);
    }

    holder.setUnderlyingReadOnly(readOnly);
  }
Пример #20
0
  @Override
  public Statement createStatement(
      int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
    checkState();

    Statement stmt = null;
    try {
      stmt = conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
    } catch (SQLException ex) {
      handleException(ex);
    }

    holder.getDataSource().initStatement(this, stmt);

    DruidPooledStatement poolableStatement = new DruidPooledStatement(this, stmt);
    holder.addTrace(poolableStatement);

    return poolableStatement;
  }
Пример #21
0
  @Override
  public SQLWarning getWarnings() throws SQLException {
    checkState();

    return conn.getWarnings();
  }
Пример #22
0
  @Override
  public NClob createNClob() throws SQLException {
    checkState();

    return conn.createNClob();
  }
Пример #23
0
  @Override
  public boolean getAutoCommit() throws SQLException {
    checkState();

    return conn.getAutoCommit();
  }
Пример #24
0
  @Override
  public int getHoldability() throws SQLException {
    checkState();

    return conn.getHoldability();
  }
Пример #25
0
  @Override
  public boolean isReadOnly() throws SQLException {
    checkState();

    return conn.isReadOnly();
  }
Пример #26
0
  @Override
  public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
    checkState();

    conn.setTypeMap(map);
  }
Пример #27
0
  @Override
  public Map<String, Class<?>> getTypeMap() throws SQLException {
    checkState();

    return conn.getTypeMap();
  }
Пример #28
0
  @Override
  public DatabaseMetaData getMetaData() throws SQLException {
    checkState();

    return conn.getMetaData();
  }
Пример #29
0
  @Override
  public int getTransactionIsolation() throws SQLException {
    checkState();

    return holder.getUnderlyingTransactionIsolation();
  }
Пример #30
0
  @Override
  public String getCatalog() throws SQLException {
    checkState();

    return conn.getCatalog();
  }