public class DruidDataSource extends DruidAbstractDataSource implements DruidDataSourceMBean, ManagedDataSource, Referenceable, Closeable, Cloneable, ConnectionPoolDataSource, MBeanRegistration
Modifier and Type | Class and Description |
---|---|
class |
DruidDataSource.CreateConnectionTask |
class |
DruidDataSource.CreateConnectionThread |
class |
DruidDataSource.DestroyConnectionThread |
class |
DruidDataSource.DestroyTask |
class |
DruidDataSource.LogStatsThread |
DruidAbstractDataSource.PhysicalConnectionInfo
Modifier and Type | Field and Description |
---|---|
static ThreadLocal<Long> |
waitNanosLocal |
DEFAULT_INITIAL_SIZE, DEFAULT_MAX_ACTIVE_SIZE, DEFAULT_MAX_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_MAX_IDLE, DEFAULT_MAX_WAIT, DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_MIN_IDLE, DEFAULT_NUM_TESTS_PER_EVICTION_RUN, DEFAULT_PHY_TIMEOUT_MILLIS, 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
Constructor and Description |
---|
DruidDataSource() |
DruidDataSource(boolean fairLock) |
addConnectionProperty, addFilters, clearFilters, closePreapredStatement, createConnectionId, createMetaDataId, createPhysicalConnection, createPhysicalConnection, createResultSetId, createStatementId, createTransactionId, decrementCachedPreparedStatementCount, getActiveConnections, getActiveConnectionStackTrace, getCachedPreparedStatementAccessCount, getCachedPreparedStatementCount, getCachedPreparedStatementDeleteCount, getCachedPreparedStatementHitCount, getCachedPreparedStatementMissCount, getClosedPreparedStatementCount, getCommitCount, getCompositeData, getConnectionErrorRetryAttempts, getConnectionInitSqls, getConnectProperties, getCreatedTime, getCreateErrorCount, getCreateScheduler, getCreateTimespanMillis, getCreateTimespanNano, getDbType, getDefaultCatalog, getDefaultReadOnly, getDefaultTransactionIsolation, getDestroyScheduler, getDriver, getDriverClassLoader, getDriverClassName, getDriverMajorVersion, getDriverMinorVersion, getDupCloseCount, getExceptionSorter, getExceptionSorterClassName, getExecuteCount, getFilterClasses, getID, getInitialSize, getLastCreateError, getLastCreateErrorTime, getLastCreateErrorTimeMillis, getLastError, getLastErrorTime, getLastErrorTimeMillis, getLoginTimeout, getLogWriter, getMaxActive, getMaxCreateTaskCount, getMaxEvictableIdleTimeMillis, getMaxIdle, getMaxOpenPreparedStatements, getMaxPoolPreparedStatementPerConnectionSize, getMaxWait, getMaxWaitThreadCount, getMinEvictableIdleTimeMillis, getMinIdle, getName, getNotFullTimeoutRetryCount, getNumTestsPerEvictionRun, getObjectName, getParentLogger, getPassword, getPasswordCallback, getPhyTimeoutMillis, 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, initPhysicalConnection, isAccessToUnderlyingConnectionAllowed, isAsyncCloseConnectionEnable, isBreakAfterAcquireFailure, isClearFiltersEnable, isDefaultAutoCommit, isDupCloseLogEnable, isFailFast, isInited, isInitGlobalVariants, isInitVariants, isLogAbandoned, isOracle, isPoolPreparedStatements, isRemoveAbandoned, isSharePreparedStatements, isTestOnBorrow, isTestOnReturn, isTestWhileIdle, isUseLocalSessionState, isUseOracleImplicitCache, isUseUnfairLock, setAccessToUnderlyingConnectionAllowed, setAsyncCloseConnectionEnable, setBreakAfterAcquireFailure, setClearFiltersEnable, setConnectionErrorRetryAttempts, setConnectionInitSqls, setConnectionProperties, setCreateScheduler, setDbType, setDefaultAutoCommit, setDefaultCatalog, setDefaultReadOnly, setDefaultTransactionIsolation, setDestroyScheduler, setDriver, setDriverClassLoader, setDriverClassName, setDupCloseLogEnable, setExceptionSorter, setExceptionSorter, setExceptionSorterClassName, setFailFast, setFilters, setInitGlobalVariants, setInitialSize, setInitVariants, setLogAbandoned, setLoginTimeout, setLogWriter, setMaxCreateTaskCount, setMaxEvictableIdleTimeMillis, setMaxIdle, setMaxOpenPreparedStatements, setMaxPoolPreparedStatementPerConnectionSize, setMaxWait, setMaxWaitThreadCount, setMinEvictableIdleTimeMillis, setMinIdle, setName, setNotFullTimeoutRetryCount, setNumTestsPerEvictionRun, setObjectName, setOracle, setPassword, setPasswordCallback, setPasswordCallbackClassName, setPhyTimeoutMillis, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getObjectName, getTimeBetweenLogStatsMillis, setConnectionProperties, setStatLoggerClassName, setTimeBetweenLogStatsMillis
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
getObjectName, setObjectName
getLoginTimeout, getLogWriter, getParentLogger, setLoginTimeout, setLogWriter
public static ThreadLocal<Long> waitNanosLocal
public DruidDataSource()
public DruidDataSource(boolean fairLock)
public boolean isAsyncInit()
public void setAsyncInit(boolean asyncInit)
public void configFromPropety(Properties properties)
public boolean isKillWhenSocketReadTimeout()
public void setKillWhenSocketReadTimeout(boolean killWhenSocketTimeOut)
public boolean isUseGlobalDataSourceStat()
public void setUseGlobalDataSourceStat(boolean useGlobalDataSourceStat)
public boolean isKeepAlive()
public void setKeepAlive(boolean keepAlive)
public String getInitStackTrace()
public boolean isResetStatEnable()
isResetStatEnable
in interface DruidDataSourceMBean
public void setResetStatEnable(boolean resetStatEnable)
setResetStatEnable
in interface DruidDataSourceMBean
public long getDiscardCount()
getDiscardCount
in interface DruidDataSourceMBean
public void restart() throws SQLException
SQLException
public void resetStat()
resetStat
in interface DruidDataSourceMBean
public long getResetCount()
getResetCount
in interface DruidDataSourceMBean
public boolean isEnable()
isEnable
in interface DruidDataSourceMBean
isEnable
in interface ManagedDataSource
public void setEnable(boolean enable)
setEnable
in interface ManagedDataSource
public void setPoolPreparedStatements(boolean value)
setPoolPreparedStatements
in interface DruidDataSourceMBean
setPoolPreparedStatements
in class DruidAbstractDataSource
public void setMaxActive(int maxActive)
setMaxActive
in interface DruidAbstractDataSourceMBean
setMaxActive
in class DruidAbstractDataSource
public void setConnectProperties(Properties properties)
setConnectProperties
in class DruidAbstractDataSource
public void init() throws SQLException
SQLException
public DruidPooledConnection getConnection() throws SQLException
getConnection
in interface DataSource
SQLException
public DruidPooledConnection getConnection(long maxWaitMillis) throws SQLException
SQLException
public PooledConnection getPooledConnection() throws SQLException
getPooledConnection
in interface ConnectionPoolDataSource
SQLException
public PooledConnection getPooledConnection(String user, String password) throws SQLException
getPooledConnection
in interface ConnectionPoolDataSource
SQLException
public DruidPooledConnection getConnectionDirect(long maxWaitMillis) throws SQLException
SQLException
public void discardConnection(Connection realConnection)
discardConnection
in class DruidAbstractDataSource
realConnection
- public void handleConnectionException(DruidPooledConnection pooledConnection, Throwable t) throws SQLException
handleConnectionException
in class DruidAbstractDataSource
SQLException
public long getRecycleErrorCount()
public void clearStatementCache() throws SQLException
clearStatementCache
in interface DruidDataSourceMBean
SQLException
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public void registerMbean()
public void unregisterMbean()
public boolean isMbeanRegistered()
public Connection getConnection(String username, String password) throws SQLException
getConnection
in interface DataSource
SQLException
public long getCreateCount()
getCreateCount
in interface DruidAbstractDataSourceMBean
public long getDestroyCount()
getDestroyCount
in interface DruidAbstractDataSourceMBean
public long getConnectCount()
getConnectCount
in interface DruidAbstractDataSourceMBean
public long getCloseCount()
getCloseCount
in interface DruidAbstractDataSourceMBean
public long getConnectErrorCount()
getConnectErrorCount
in interface DruidAbstractDataSourceMBean
public int getPoolingCount()
getPoolingCount
in interface DruidAbstractDataSourceMBean
public int getPoolingPeak()
getPoolingPeak
in interface DruidDataSourceMBean
public Date getPoolingPeakTime()
getPoolingPeakTime
in interface DruidDataSourceMBean
public long getRecycleCount()
getRecycleCount
in interface DruidAbstractDataSourceMBean
public int getActiveCount()
getActiveCount
in interface DruidAbstractDataSourceMBean
public void logStats()
public DruidDataSourceStatValue getStatValueAndReset()
public long getRemoveAbandonedCount()
getRemoveAbandonedCount
in interface DruidAbstractDataSourceMBean
public int removeAbandoned()
removeAbandoned
in interface DruidDataSourceMBean
public Reference getReference() throws NamingException
getReference
in interface Referenceable
NamingException
public List<String> getFilterClassNames()
getFilterClassNames
in interface DruidAbstractDataSourceMBean
public int getRawDriverMajorVersion()
getRawDriverMajorVersion
in interface DruidAbstractDataSourceMBean
getRawDriverMajorVersion
in class DruidAbstractDataSource
public int getRawDriverMinorVersion()
getRawDriverMinorVersion
in interface DruidAbstractDataSourceMBean
getRawDriverMinorVersion
in class DruidAbstractDataSource
public String getProperties()
getProperties
in interface DruidAbstractDataSourceMBean
getProperties
in class DruidAbstractDataSource
public void shrink()
shrink
in interface DruidDataSourceMBean
public void shrink(boolean checkTime)
public void shrink(boolean checkTime, boolean keepAlive)
public int getWaitThreadCount()
getWaitThreadCount
in interface DruidDataSourceMBean
public long getNotEmptyWaitCount()
getNotEmptyWaitCount
in interface DruidDataSourceMBean
public int getNotEmptyWaitThreadCount()
getNotEmptyWaitThreadCount
in interface DruidDataSourceMBean
public int getNotEmptyWaitThreadPeak()
public long getNotEmptySignalCount()
getNotEmptySignalCount
in interface DruidDataSourceMBean
public long getNotEmptyWaitMillis()
getNotEmptyWaitMillis
in interface DruidDataSourceMBean
public long getNotEmptyWaitNanos()
getNotEmptyWaitNanos
in interface DruidDataSourceMBean
public int getLockQueueLength()
getLockQueueLength
in interface DruidDataSourceMBean
public int getActivePeak()
getActivePeak
in interface DruidDataSourceMBean
getActivePeak
in class DruidAbstractDataSource
public Date getActivePeakTime()
getActivePeakTime
in interface DruidDataSourceMBean
public String dump()
dump
in interface DruidDataSourceMBean
public long getErrorCount()
getErrorCount
in interface DruidDataSourceMBean
public void logTransaction(TransactionInfo info)
logTransaction
in class DruidAbstractDataSource
public String getVersion()
getVersion
in interface DruidDataSourceMBean
public JdbcDataSourceStat getDataSourceStat()
getDataSourceStat
in interface DataSourceProxy
public Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public DruidDataSource cloneDruidDataSource()
public JdbcSqlStat getSqlStat(int sqlId)
public JdbcSqlStat getSqlStat(long sqlId)
public Map<String,JdbcSqlStat> getSqlStatMap()
public WallProviderStatValue getWallStatValue(boolean reset)
public Lock getLock()
public boolean isWrapperFor(Class<?> iface)
isWrapperFor
in interface Wrapper
isWrapperFor
in class WrapperAdapter
public <T> T unwrap(Class<T> iface)
unwrap
in interface Wrapper
unwrap
in class WrapperAdapter
public boolean isLogDifferentThread()
public void setLogDifferentThread(boolean logDifferentThread)
public DruidPooledConnection tryGetConnection() throws SQLException
SQLException
public int fill() throws SQLException
fill
in interface DruidDataSourceMBean
SQLException
public int fill(int toCount) throws SQLException
fill
in interface DruidDataSourceMBean
SQLException
public boolean isFull()
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister
in interface MBeanRegistration
Exception
public void postRegister(Boolean registrationDone)
postRegister
in interface MBeanRegistration
public void preDeregister() throws Exception
preDeregister
in interface MBeanRegistration
Exception
public void postDeregister()
postDeregister
in interface MBeanRegistration
public boolean isClosed()
Copyright © 2013–2017 Alibaba Group. All rights reserved.