示例#1
0
 @Override
 public int getTransactionIsolation() throws SQLException {
   FilterChainImpl chain = createChain();
   int value = chain.connection_getTransactionIsolation(this);
   recycleFilterChain(chain);
   return value;
 }
  public synchronized void syncClose() throws SQLException {
    if (this.disable) {
      return;
    }

    DruidConnectionHolder holder = this.holder;
    if (holder == null) {
      if (dupCloseLogEnable) {
        LOG.error("dup close");
      }
      return;
    }

    for (ConnectionEventListener listener : holder.getConnectionEventListeners()) {
      listener.connectionClosed(new ConnectionEvent(this));
    }

    DruidAbstractDataSource dataSource = holder.getDataSource();
    List<Filter> filters = dataSource.getProxyFilters();
    if (filters.size() > 0) {
      FilterChainImpl filterChain = new FilterChainImpl(dataSource);
      filterChain.dataSource_recycle(this);
    } else {
      recycle();
    }

    this.disable = true;
  }
示例#3
0
 @Override
 public SQLXML createSQLXML() throws SQLException {
   FilterChainImpl chain = createChain();
   SQLXML value = chain.connection_createSQLXML(this);
   recycleFilterChain(chain);
   return value;
 }
示例#4
0
 @Override
 public Statement createStatement() throws SQLException {
   FilterChainImpl chain = createChain();
   Statement stmt = chain.connection_createStatement(this);
   recycleFilterChain(chain);
   return stmt;
 }
示例#5
0
 @Override
 public NClob createNClob() throws SQLException {
   FilterChainImpl chain = createChain();
   NClob value = chain.connection_createNClob(this);
   recycleFilterChain(chain);
   return value;
 }
示例#6
0
 @Override
 public DatabaseMetaData getMetaData() throws SQLException {
   FilterChainImpl chain = createChain();
   DatabaseMetaData value = chain.connection_getMetaData(this);
   recycleFilterChain(chain);
   return value;
 }
示例#7
0
 @Override
 public Map<String, Class<?>> getTypeMap() throws SQLException {
   FilterChainImpl chain = createChain();
   Map<String, Class<?>> value = chain.connection_getTypeMap(this);
   recycleFilterChain(chain);
   return value;
 }
示例#8
0
 @Override
 public String getClientInfo(String name) throws SQLException {
   FilterChainImpl chain = createChain();
   String value = chain.connection_getClientInfo(this, name);
   recycleFilterChain(chain);
   return value;
 }
示例#9
0
 @Override
 public Properties getClientInfo() throws SQLException {
   FilterChainImpl chain = createChain();
   Properties value = chain.connection_getClientInfo(this);
   recycleFilterChain(chain);
   return value;
 }
示例#10
0
 @Override
 public String getCatalog() throws SQLException {
   FilterChainImpl chain = createChain();
   String value = chain.connection_getCatalog(this);
   recycleFilterChain(chain);
   return value;
 }
示例#11
0
 @Override
 public boolean getAutoCommit() throws SQLException {
   FilterChainImpl chain = createChain();
   boolean value = chain.connection_getAutoCommit(this);
   recycleFilterChain(chain);
   return value;
 }
示例#12
0
 @Override
 public int getHoldability() throws SQLException {
   FilterChainImpl chain = createChain();
   int value = chain.connection_getHoldability(this);
   recycleFilterChain(chain);
   return value;
 }
示例#13
0
 @Override
 public void close() throws SQLException {
   FilterChainImpl chain = createChain();
   chain.connection_close(this);
   closeCount++;
   recycleFilterChain(chain);
 }
示例#14
0
 @Override
 public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
   FilterChainImpl chain = createChain();
   PreparedStatement stmt = chain.connection_prepareStatement(this, sql, autoGeneratedKeys);
   recycleFilterChain(chain);
   return stmt;
 }
示例#15
0
 @Override
 public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
   FilterChainImpl chain = createChain();
   Array value = chain.connection_createArrayOf(this, typeName, elements);
   recycleFilterChain(chain);
   return value;
 }
示例#16
0
 @Override
 public CallableStatement prepareCall(String sql) throws SQLException {
   FilterChainImpl chain = createChain();
   CallableStatement stmt = chain.connection_prepareCall(this, sql);
   recycleFilterChain(chain);
   return stmt;
 }
示例#17
0
 @Override
 public Savepoint setSavepoint(String name) throws SQLException {
   FilterChainImpl chain = createChain();
   Savepoint savepoint = chain.connection_setSavepoint(this, name);
   recycleFilterChain(chain);
   return savepoint;
 }
示例#18
0
 @Override
 public boolean isValid(int timeout) throws SQLException {
   FilterChainImpl chain = createChain();
   boolean value = chain.connection_isValid(this, timeout);
   recycleFilterChain(chain);
   return value;
 }
示例#19
0
 @Override
 public String nativeSQL(String sql) throws SQLException {
   FilterChainImpl chain = createChain();
   String value = chain.connection_nativeSQL(this, sql);
   recycleFilterChain(chain);
   return value;
 }
示例#20
0
 @Override
 public boolean isReadOnly() throws SQLException {
   FilterChainImpl chain = createChain();
   boolean value = chain.connection_isReadOnly(this);
   recycleFilterChain(chain);
   return value;
 }
示例#21
0
 @Override
 public SQLWarning getWarnings() throws SQLException {
   FilterChainImpl chain = createChain();
   SQLWarning value = chain.connection_getWarnings(this);
   recycleFilterChain(chain);
   return value;
 }
示例#22
0
 @Override
 public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
   FilterChainImpl chain = createChain();
   Struct value = chain.connection_createStruct(this, typeName, attributes);
   recycleFilterChain(chain);
   return value;
 }
示例#23
0
 @Override
 public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
   FilterChainImpl chain = createChain();
   PreparedStatement stmt = chain.connection_prepareStatement(this, sql, columnNames);
   recycleFilterChain(chain);
   return stmt;
 }
示例#24
0
 @Override
 public void rollback(Savepoint savepoint) throws SQLException {
   FilterChainImpl chain = createChain();
   chain.connection_rollback(this, savepoint);
   recycleFilterChain(chain);
   if (transcationInfo != null) {
     transcationInfo.setEndTimeMillis();
   }
 }
示例#25
0
 @Override
 public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
     throws SQLException {
   FilterChainImpl chain = createChain();
   PreparedStatement stmt =
       chain.connection_prepareStatement(this, sql, resultSetType, resultSetConcurrency);
   recycleFilterChain(chain);
   return stmt;
 }
示例#26
0
 @Override
 public Statement createStatement(
     int resultSetType, //
     int resultSetConcurrency //
     ) throws SQLException {
   FilterChainImpl chain = createChain();
   Statement stmt = chain.connection_createStatement(this, resultSetType, resultSetConcurrency);
   recycleFilterChain(chain);
   return stmt;
 }
示例#27
0
  @Override
  public void commit() throws SQLException {
    FilterChainImpl chain = createChain();
    chain.connection_commit(this);

    if (transcationInfo != null) {
      transcationInfo.setEndTimeMillis();
    }
    recycleFilterChain(chain);
  }
示例#28
0
 @Override
 public CallableStatement prepareCall(
     String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
     throws SQLException {
   FilterChainImpl chain = createChain();
   CallableStatement stmt =
       chain.connection_prepareCall(
           this, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
   recycleFilterChain(chain);
   return stmt;
 }
示例#29
0
  @Override
  public void setAutoCommit(boolean autoCommit) throws SQLException {
    if (!autoCommit) {
      if (transcationInfo == null) {
        long transactionId = this.dataSource.createTransactionId();
        transcationInfo = new TransactionInfo(transactionId);
        this.getAttributes()
            .put(StatFilter.ATTR_TRANSACTION, transcationInfo); // compatible for druid 0.1.18
      }
    } else {
      transcationInfo = null;
    }

    FilterChainImpl chain = createChain();
    chain.connection_setAutoCommit(this, autoCommit);
    recycleFilterChain(chain);
  }
示例#30
0
 public void recycleFilterChain(FilterChainImpl chain) {
   chain.reset();
   this.filterChain = chain;
 }