com.alibaba.druid.pool
类 DruidDataSource

java.lang.Object
  继承者 com.alibaba.druid.pool.WrapperAdapter
      继承者 com.alibaba.druid.pool.DruidAbstractDataSource
          继承者 com.alibaba.druid.pool.DruidDataSource
所有已实现的接口:
DruidAbstractDataSourceMBean, DruidDataSourceMBean, ManagedDataSource, DataSourceProxy, Closeable, Serializable, Cloneable, Wrapper, Referenceable, CommonDataSource, ConnectionPoolDataSource, DataSource
直接已知子类:
DruidXADataSource

public class DruidDataSource
extends DruidAbstractDataSource
implements DruidDataSourceMBean, ManagedDataSource, Referenceable, Closeable, Cloneable, ConnectionPoolDataSource

作者:
ljw, wenshao
另请参见:
序列化表格

嵌套类摘要
 class DruidDataSource.CreateConnectionThread
           
 class DruidDataSource.DestroyConnectionThread
           
 class DruidDataSource.LogStatsThread
           
 
字段摘要
static ThreadLocal<Long> waitNanosLocal
           
 
从类 com.alibaba.druid.pool.DruidAbstractDataSource 继承的字段
DEFAULT_INITIAL_SIZE, DEFAULT_MAX_ACTIVE_SIZE, DEFAULT_MAX_IDLE, DEFAULT_MAX_WAIT, DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_MIN_IDLE, DEFAULT_NUM_TESTS_PER_EVICTION_RUN, DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN, DEFAULT_TIME_BETWEEN_CONNECT_ERROR_MILLIS, DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, DEFAULT_VALIDATION_QUERY, DEFAULT_WHILE_IDLE
 
构造方法摘要
DruidDataSource()
           
DruidDataSource(boolean fairLock)
           
 
方法摘要
 void clearStatementCache()
           
 Object clone()
           
 DruidDataSource cloneDruidDataSource()
           
 void close()
          close datasource
 void configFromPropety(Properties properties)
           
 void discardConnection(Connection realConnection)
          抛弃连接,不进行回收,而是抛弃
 String dump()
           
 int getActiveCount()
           
 int getActivePeak()
           
 Date getActivePeakTime()
           
 long getCloseCount()
           
 long getConnectCount()
           
 long getConnectErrorCount()
           
 DruidPooledConnection getConnection()
           
 DruidPooledConnection getConnection(long maxWaitMillis)
           
 Connection getConnection(String username, String password)
           
 DruidPooledConnection getConnectionDirect(long maxWaitMillis)
           
 long getCreateCount()
           
 JdbcDataSourceStat getDataSourceStat()
           
 long getDestroyCount()
           
 long getDiscardCount()
           
 long getErrorCount()
           
 List<String> getFilterClassNames()
           
 String getInitStackTrace()
           
 Lock getLock()
           
 int getLockQueueLength()
           
 long getNotEmptySignalCount()
           
 long getNotEmptyWaitCount()
           
 long getNotEmptyWaitMillis()
           
 long getNotEmptyWaitNanos()
           
 int getNotEmptyWaitThreadCount()
           
 int getNotEmptyWaitThreadPeak()
           
 PooledConnection getPooledConnection()
           
 PooledConnection getPooledConnection(String user, String password)
           
 List<Map<String,Object>> getPoolingConnectionInfo()
           
 int getPoolingCount()
           
 int getPoolingPeak()
           
 Date getPoolingPeakTime()
           
 String getProperties()
           
 int getRawDriverMajorVersion()
           
 int getRawDriverMinorVersion()
           
 long getRecycleCount()
           
 long getRecycleErrorCount()
           
 Reference getReference()
           
 long getRemoveAbandonedCount()
           
 long getResetCount()
           
 JdbcSqlStat getSqlStat(int sqlId)
           
 JdbcSqlStat getSqlStat(long sqlId)
           
 Map<String,JdbcSqlStat> getSqlStatMap()
           
 Map<String,Object> getStatData()
           
 Map<String,Object> getStatDataForMBean()
           
 DruidDataSourceStatValue getStatValueAndReset()
           
 String getVersion()
           
 int getWaitThreadCount()
           
 Map<String,Object> getWallStatMap()
           
 WallProviderStatValue getWallStatValue(boolean reset)
           
 void handleConnectionException(DruidPooledConnection pooledConnection, Throwable t)
           
 void init()
           
 boolean isEnable()
           
 boolean isInited()
           
 boolean isMbeanRegistered()
           
 boolean isResetStatEnable()
           
 boolean isUseGloalDataSourceStat()
           
 boolean isWrapperFor(Class<?> iface)
           
 void logStats()
           
 void logTransaction(TransactionInfo info)
           
 void registerMbean()
           
 int removeAbandoned()
           
 void resetStat()
           
 void restart()
           
 void setConnectProperties(Properties properties)
           
 void setEnable(boolean enable)
           
 void setMaxActive(int maxActive)
           
 void setPoolPreparedStatements(boolean value)
           
 void setResetStatEnable(boolean resetStatEnable)
           
 void setUseGloalDataSourceStat(boolean useGloalDataSourceStat)
           
 void shrink()
           
 void shrink(boolean checkTime)
           
 String toString()
           
 void unregisterMbean()
           
<T> T
unwrap(Class<T> iface)
           
 
从类 com.alibaba.druid.pool.DruidAbstractDataSource 继承的方法
addConnectionProperty, addFilters, clearFilters, closePreapredStatement, createConnectionId, createPhysicalConnection, createPhysicalConnection, createResultSetId, createStatementId, createTransactionId, decrementCachedPreparedStatementCount, getActiveConnections, getActiveConnectionStackTrace, getCachedPreparedStatementAccessCount, getCachedPreparedStatementCount, getCachedPreparedStatementDeleteCount, getCachedPreparedStatementHitCount, getCachedPreparedStatementMissCount, getClosedPreparedStatementCount, getCommitCount, getCompositeData, getConnectionErrorRetryAttempts, getConnectionInitSqls, getConnectProperties, getCreatedTime, getCreateErrorCount, getCreateTimespanMillis, getCreateTimespanNano, getDbType, getDefaultCatalog, getDefaultReadOnly, getDefaultTransactionIsolation, getDriver, getDriverClassLoader, getDriverClassName, getDriverMajorVersion, getDriverMinorVersion, getDupCloseCount, getExceptionSorter, getExceptionSorterClassName, getExecuteCount, getFilterClasses, getID, getInitialSize, getLastCreateError, getLastCreateErrorTime, getLastCreateErrorTimeMillis, getLastError, getLastErrorTime, getLastErrorTimeMillis, getLoginTimeout, getLogWriter, getMaxActive, getMaxIdle, getMaxOpenPreparedStatements, getMaxPoolPreparedStatementPerConnectionSize, getMaxWait, getMaxWaitThreadCount, getMinEvictableIdleTimeMillis, getMinIdle, getName, getNumTestsPerEvictionRun, getObjectName, getParentLogger, getPassword, getPasswordCallback, getPreparedStatementCount, getProxyFilters, getQueryTimeout, getRawDriver, getRawJdbcUrl, getRemoveAbandonedTimeout, getRemoveAbandonedTimeoutMillis, getRollbackCount, getStartTransactionCount, getStatLogger, getTimeBetweenConnectErrorMillis, getTimeBetweenEvictionRunsMillis, getTimeBetweenLogStatsMillis, getTransactionHistogram, getTransactionHistogramRanges, getTransactionHistogramValues, getTransactionQueryTimeout, getTransactionThresholdMillis, getUrl, getUserCallback, getUsername, getValidationQuery, getValidationQueryTimeout, getValidConnectionChecker, getValidConnectionCheckerClassName, incrementCachedPreparedStatementCount, incrementCachedPreparedStatementDeleteCount, incrementCachedPreparedStatementHitCount, incrementCachedPreparedStatementMissCount, incrementClosedPreparedStatementCount, incrementCommitCount, incrementDupCloseCount, incrementExecuteCount, incrementPreparedStatementCount, incrementRollbackCount, incrementStartTransactionCount, initPhysicalConnection, isAccessToUnderlyingConnectionAllowed, isBreakAfterAcquireFailure, isClearFiltersEnable, isDefaultAutoCommit, isDupCloseLogEnable, isLogAbandoned, isOracle, isPoolPreparedStatements, isRemoveAbandoned, isSharePreparedStatements, isTestOnBorrow, isTestOnReturn, isTestWhileIdle, isUseLocalSessionState, isUseOracleImplicitCache, isUseUnfairLock, setAccessToUnderlyingConnectionAllowed, setBreakAfterAcquireFailure, setClearFiltersEnable, setConnectionErrorRetryAttempts, setConnectionInitSqls, setConnectionProperties, setDbType, setDefaultAutoCommit, setDefaultCatalog, setDefaultReadOnly, setDefaultTransactionIsolation, setDriver, setDriverClassLoader, setDriverClassName, setDupCloseLogEnable, setExceptionSorter, setExceptionSorter, setExceptionSorterClassName, setFilters, setInitialSize, setLogAbandoned, setLoginTimeout, setLogWriter, setMaxIdle, setMaxOpenPreparedStatements, setMaxPoolPreparedStatementPerConnectionSize, setMaxWait, setMaxWaitThreadCount, setMinEvictableIdleTimeMillis, setMinIdle, setName, setNumTestsPerEvictionRun, setObjectName, setOracle, setPassword, setPasswordCallback, setPasswordCallbackClassName, setProxyFilters, setQueryTimeout, setRemoveAbandoned, setRemoveAbandonedTimeout, setRemoveAbandonedTimeoutMillis, setSharePreparedStatements, setStatLogger, setStatLoggerClassName, setTestOnBorrow, setTestOnReturn, setTestWhileIdle, setTimeBetweenConnectErrorMillis, setTimeBetweenEvictionRunsMillis, setTimeBetweenLogStatsMillis, setTransactionQueryTimeout, setTransactionThresholdMillis, setUrl, setUseLocalSessionState, setUseOracleImplicitCache, setUserCallback, setUsername, setUseUnfairLock, setValidationQuery, setValidationQueryTimeout, setValidConnectionChecker, setValidConnectionCheckerClassName, validateConnection
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
从接口 com.alibaba.druid.pool.DruidDataSourceMBean 继承的方法
getObjectName, getTimeBetweenLogStatsMillis, setConnectionProperties, setStatLoggerClassName, setTimeBetweenLogStatsMillis
 
从接口 com.alibaba.druid.pool.DruidAbstractDataSourceMBean 继承的方法
getActiveConnectionStackTrace, getCachedPreparedStatementAccessCount, getCachedPreparedStatementCount, getCachedPreparedStatementDeleteCount, getCachedPreparedStatementHitCount, getCachedPreparedStatementMissCount, getClosedPreparedStatementCount, getCommitCount, getConnectionErrorRetryAttempts, getCreatedTime, getCreateErrorCount, getCreateTimespanMillis, getDbType, getDefaultCatalog, getDefaultReadOnly, getDefaultTransactionIsolation, getDriverClassName, getDriverMajorVersion, getDriverMinorVersion, getDupCloseCount, getExceptionSorterClassName, getInitialSize, getLoginTimeout, getMaxActive, getMaxIdle, getMaxOpenPreparedStatements, getMaxPoolPreparedStatementPerConnectionSize, getMaxWait, getMaxWaitThreadCount, getMinEvictableIdleTimeMillis, getMinIdle, getName, getPreparedStatementCount, getQueryTimeout, getRemoveAbandonedTimeoutMillis, getRollbackCount, getStartTransactionCount, getTimeBetweenConnectErrorMillis, getTimeBetweenEvictionRunsMillis, getTransactionHistogramValues, getTransactionQueryTimeout, getTransactionThresholdMillis, getUrl, getUsername, getValidationQuery, getValidationQueryTimeout, getValidConnectionCheckerClassName, isBreakAfterAcquireFailure, isDefaultAutoCommit, isLogAbandoned, isPoolPreparedStatements, isRemoveAbandoned, isSharePreparedStatements, isTestOnBorrow, isTestOnReturn, isTestWhileIdle, isUseOracleImplicitCache, setLogAbandoned, setMaxPoolPreparedStatementPerConnectionSize, setTestOnBorrow, setTestWhileIdle, setTransactionThresholdMillis, setUseOracleImplicitCache
 
从接口 com.alibaba.druid.pool.ManagedDataSource 继承的方法
getObjectName, setObjectName
 
从接口 javax.sql.CommonDataSource 继承的方法
getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
 

字段详细信息

waitNanosLocal

public static ThreadLocal<Long> waitNanosLocal
构造方法详细信息

DruidDataSource

public DruidDataSource()

DruidDataSource

public DruidDataSource(boolean fairLock)
方法详细信息

configFromPropety

public void configFromPropety(Properties properties)

isUseGloalDataSourceStat

public boolean isUseGloalDataSourceStat()

setUseGloalDataSourceStat

public void setUseGloalDataSourceStat(boolean useGloalDataSourceStat)

getInitStackTrace

public String getInitStackTrace()

isResetStatEnable

public boolean isResetStatEnable()
指定者:
接口 DruidDataSourceMBean 中的 isResetStatEnable

setResetStatEnable

public void setResetStatEnable(boolean resetStatEnable)
指定者:
接口 DruidDataSourceMBean 中的 setResetStatEnable

getDiscardCount

public long getDiscardCount()
指定者:
接口 DruidDataSourceMBean 中的 getDiscardCount

restart

public void restart()

resetStat

public void resetStat()
指定者:
接口 DruidDataSourceMBean 中的 resetStat

getResetCount

public long getResetCount()
指定者:
接口 DruidDataSourceMBean 中的 getResetCount

isEnable

public boolean isEnable()
指定者:
接口 DruidDataSourceMBean 中的 isEnable
指定者:
接口 ManagedDataSource 中的 isEnable

setEnable

public void setEnable(boolean enable)
指定者:
接口 ManagedDataSource 中的 setEnable

setPoolPreparedStatements

public void setPoolPreparedStatements(boolean value)
指定者:
接口 DruidDataSourceMBean 中的 setPoolPreparedStatements
指定者:
DruidAbstractDataSource 中的 setPoolPreparedStatements

setMaxActive

public void setMaxActive(int maxActive)
指定者:
接口 DruidAbstractDataSourceMBean 中的 setMaxActive
指定者:
DruidAbstractDataSource 中的 setMaxActive

setConnectProperties

public void setConnectProperties(Properties properties)
指定者:
DruidAbstractDataSource 中的 setConnectProperties

isInited

public boolean isInited()

init

public void init()
          throws SQLException
抛出:
SQLException

getConnection

public DruidPooledConnection getConnection()
                                    throws SQLException
指定者:
接口 DataSource 中的 getConnection
抛出:
SQLException

getConnection

public DruidPooledConnection getConnection(long maxWaitMillis)
                                    throws SQLException
抛出:
SQLException

getPooledConnection

public PooledConnection getPooledConnection()
                                     throws SQLException
指定者:
接口 ConnectionPoolDataSource 中的 getPooledConnection
抛出:
SQLException

getPooledConnection

public PooledConnection getPooledConnection(String user,
                                            String password)
                                     throws SQLException
指定者:
接口 ConnectionPoolDataSource 中的 getPooledConnection
抛出:
SQLException

getConnectionDirect

public DruidPooledConnection getConnectionDirect(long maxWaitMillis)
                                          throws SQLException
抛出:
SQLException

discardConnection

public void discardConnection(Connection realConnection)
抛弃连接,不进行回收,而是抛弃

指定者:
DruidAbstractDataSource 中的 discardConnection
参数:
realConnection -
抛出:
SQLException

handleConnectionException

public void handleConnectionException(DruidPooledConnection pooledConnection,
                                      Throwable t)
                               throws SQLException
指定者:
DruidAbstractDataSource 中的 handleConnectionException
抛出:
SQLException

getRecycleErrorCount

public long getRecycleErrorCount()

clearStatementCache

public void clearStatementCache()
                         throws SQLException
指定者:
接口 DruidDataSourceMBean 中的 clearStatementCache
抛出:
SQLException

close

public void close()
close datasource

指定者:
接口 Closeable 中的 close

registerMbean

public void registerMbean()

unregisterMbean

public void unregisterMbean()

isMbeanRegistered

public boolean isMbeanRegistered()

getConnection

public Connection getConnection(String username,
                                String password)
                         throws SQLException
指定者:
接口 DataSource 中的 getConnection
抛出:
SQLException

getCreateCount

public long getCreateCount()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getCreateCount

getDestroyCount

public long getDestroyCount()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getDestroyCount

getConnectCount

public long getConnectCount()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getConnectCount

getCloseCount

public long getCloseCount()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getCloseCount

getConnectErrorCount

public long getConnectErrorCount()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getConnectErrorCount

getPoolingCount

public int getPoolingCount()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getPoolingCount

getPoolingPeak

public int getPoolingPeak()
指定者:
接口 DruidDataSourceMBean 中的 getPoolingPeak

getPoolingPeakTime

public Date getPoolingPeakTime()
指定者:
接口 DruidDataSourceMBean 中的 getPoolingPeakTime

getRecycleCount

public long getRecycleCount()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getRecycleCount

getActiveCount

public int getActiveCount()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getActiveCount

logStats

public void logStats()

getStatValueAndReset

public DruidDataSourceStatValue getStatValueAndReset()

getRemoveAbandonedCount

public long getRemoveAbandonedCount()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getRemoveAbandonedCount

removeAbandoned

public int removeAbandoned()
指定者:
接口 DruidDataSourceMBean 中的 removeAbandoned

getReference

public Reference getReference()
                       throws NamingException
指定者:
接口 Referenceable 中的 getReference
抛出:
NamingException

getFilterClassNames

public List<String> getFilterClassNames()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getFilterClassNames

getRawDriverMajorVersion

public int getRawDriverMajorVersion()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getRawDriverMajorVersion
指定者:
DruidAbstractDataSource 中的 getRawDriverMajorVersion

getRawDriverMinorVersion

public int getRawDriverMinorVersion()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getRawDriverMinorVersion
指定者:
DruidAbstractDataSource 中的 getRawDriverMinorVersion

getProperties

public String getProperties()
指定者:
接口 DruidAbstractDataSourceMBean 中的 getProperties
指定者:
DruidAbstractDataSource 中的 getProperties

shrink

public void shrink()
指定者:
接口 DruidDataSourceMBean 中的 shrink

shrink

public void shrink(boolean checkTime)

getWaitThreadCount

public int getWaitThreadCount()
指定者:
接口 DruidDataSourceMBean 中的 getWaitThreadCount

getNotEmptyWaitCount

public long getNotEmptyWaitCount()
指定者:
接口 DruidDataSourceMBean 中的 getNotEmptyWaitCount

getNotEmptyWaitThreadCount

public int getNotEmptyWaitThreadCount()
指定者:
接口 DruidDataSourceMBean 中的 getNotEmptyWaitThreadCount

getNotEmptyWaitThreadPeak

public int getNotEmptyWaitThreadPeak()

getNotEmptySignalCount

public long getNotEmptySignalCount()
指定者:
接口 DruidDataSourceMBean 中的 getNotEmptySignalCount

getNotEmptyWaitMillis

public long getNotEmptyWaitMillis()
指定者:
接口 DruidDataSourceMBean 中的 getNotEmptyWaitMillis

getNotEmptyWaitNanos

public long getNotEmptyWaitNanos()
指定者:
接口 DruidDataSourceMBean 中的 getNotEmptyWaitNanos

getLockQueueLength

public int getLockQueueLength()
指定者:
接口 DruidDataSourceMBean 中的 getLockQueueLength

getActivePeak

public int getActivePeak()
指定者:
接口 DruidDataSourceMBean 中的 getActivePeak
指定者:
DruidAbstractDataSource 中的 getActivePeak

getActivePeakTime

public Date getActivePeakTime()
指定者:
接口 DruidDataSourceMBean 中的 getActivePeakTime

dump

public String dump()
指定者:
接口 DruidDataSourceMBean 中的 dump

getErrorCount

public long getErrorCount()
指定者:
接口 DruidDataSourceMBean 中的 getErrorCount

toString

public String toString()
覆盖:
Object 中的 toString

getPoolingConnectionInfo

public List<Map<String,Object>> getPoolingConnectionInfo()

logTransaction

public void logTransaction(TransactionInfo info)
指定者:
DruidAbstractDataSource 中的 logTransaction

getVersion

public String getVersion()
指定者:
接口 DruidDataSourceMBean 中的 getVersion

getDataSourceStat

public JdbcDataSourceStat getDataSourceStat()
指定者:
接口 DataSourceProxy 中的 getDataSourceStat

clone

public Object clone()
             throws CloneNotSupportedException
覆盖:
Object 中的 clone
抛出:
CloneNotSupportedException

cloneDruidDataSource

public DruidDataSource cloneDruidDataSource()

getStatDataForMBean

public Map<String,Object> getStatDataForMBean()

getStatData

public Map<String,Object> getStatData()

getSqlStat

public JdbcSqlStat getSqlStat(int sqlId)

getSqlStat

public JdbcSqlStat getSqlStat(long sqlId)

getSqlStatMap

public Map<String,JdbcSqlStat> getSqlStatMap()

getWallStatMap

public Map<String,Object> getWallStatMap()

getWallStatValue

public WallProviderStatValue getWallStatValue(boolean reset)

getLock

public Lock getLock()

isWrapperFor

public boolean isWrapperFor(Class<?> iface)
指定者:
接口 Wrapper 中的 isWrapperFor
覆盖:
WrapperAdapter 中的 isWrapperFor

unwrap

public <T> T unwrap(Class<T> iface)
指定者:
接口 Wrapper 中的 unwrap
覆盖:
WrapperAdapter 中的 unwrap


Copyright © 2013 Alibaba Group. All Rights Reserved.