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, getAndResetExecuteCount, 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, getExecuteBatchCount, getExecuteCount, getExecuteCount2, getExecuteQueryCount, getExecuteUpdateCount, 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, getOnFatalErrorMaxActive, getParentLogger, getPassword, getPasswordCallback, getPhyMaxUseCount, 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, handleConnectionException, incrementCachedPreparedStatementCount, incrementCachedPreparedStatementDeleteCount, incrementCachedPreparedStatementHitCount, incrementCachedPreparedStatementMissCount, incrementClosedPreparedStatementCount, incrementCommitCount, incrementDupCloseCount, incrementExecuteBatchCount, incrementExecuteCount, incrementExecuteQueryCount, incrementExecuteUpdateCount, incrementPreparedStatementCount, incrementRollbackCount, incrementStartTransactionCount, initPhysicalConnection, initPhysicalConnection, isAccessToUnderlyingConnectionAllowed, isAsyncCloseConnectionEnable, isBreakAfterAcquireFailure, isClearFiltersEnable, isDefaultAutoCommit, isDupCloseLogEnable, isFailFast, isInited, isInitExceptionThrow, isInitGlobalVariants, isInitVariants, isLogAbandoned, isOnFatalError, 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, setInitExceptionThrow, setInitGlobalVariants, setInitialSize, setInitVariants, setLogAbandoned, setLoginTimeout, setLogWriter, setMaxCreateTaskCount, setMaxEvictableIdleTimeMillis, setMaxIdle, setMaxOpenPreparedStatements, setMaxPoolPreparedStatementPerConnectionSize, setMaxWait, setMaxWaitThreadCount, setMinEvictableIdleTimeMillis, setMinIdle, setName, setNotFullTimeoutRetryCount, setNumTestsPerEvictionRun, setObjectName, setOnFatalErrorMaxActive, setOracle, setPassword, setPasswordCallback, setPasswordCallbackClassName, setPhyMaxUseCount, 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, validateConnectionequals, getClass, hashCode, notify, notifyAll, wait, wait, waitgetObjectName, getTimeBetweenLogStatsMillis, setConnectionProperties, setStatLoggerClassName, setTimeBetweenLogStatsMillisgetActiveConnectionStackTrace, 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, setUseOracleImplicitCachegetObjectName, setObjectNamegetLoginTimeout, getLogWriter, getParentLogger, setLoginTimeout, setLogWriterpublic 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()
isUseGlobalDataSourceStat in interface DruidDataSourceMBeanpublic void setUseGlobalDataSourceStat(boolean useGlobalDataSourceStat)
public boolean isKeepAlive()
public void setKeepAlive(boolean keepAlive)
public String getInitStackTrace()
public boolean isResetStatEnable()
isResetStatEnable in interface DruidDataSourceMBeanpublic void setResetStatEnable(boolean resetStatEnable)
setResetStatEnable in interface DruidDataSourceMBeanpublic long getDiscardCount()
getDiscardCount in interface DruidDataSourceMBeanpublic void restart()
throws SQLException
SQLExceptionpublic void resetStat()
resetStat in interface DruidDataSourceMBeanpublic long getResetCount()
getResetCount in interface DruidDataSourceMBeanpublic boolean isEnable()
isEnable in interface DruidDataSourceMBeanisEnable in interface ManagedDataSourcepublic void setEnable(boolean enable)
setEnable in interface ManagedDataSourcepublic void setPoolPreparedStatements(boolean value)
setPoolPreparedStatements in interface DruidDataSourceMBeansetPoolPreparedStatements in class DruidAbstractDataSourcepublic void setMaxActive(int maxActive)
setMaxActive in interface DruidAbstractDataSourceMBeansetMaxActive in class DruidAbstractDataSourcepublic void setConnectProperties(Properties properties)
setConnectProperties in class DruidAbstractDataSourcepublic void init()
throws SQLException
SQLExceptionpublic DruidPooledConnection getConnection() throws SQLException
getConnection in interface DataSourceSQLExceptionpublic DruidPooledConnection getConnection(long maxWaitMillis) throws SQLException
SQLExceptionpublic PooledConnection getPooledConnection() throws SQLException
getPooledConnection in interface ConnectionPoolDataSourceSQLExceptionpublic PooledConnection getPooledConnection(String user, String password) throws SQLException
getPooledConnection in interface ConnectionPoolDataSourceSQLExceptionpublic DruidPooledConnection getConnectionDirect(long maxWaitMillis) throws SQLException
SQLExceptionpublic void discardConnection(Connection realConnection)
discardConnection in class DruidAbstractDataSourcerealConnection - public void handleConnectionException(DruidPooledConnection pooledConnection, Throwable t, String sql) throws SQLException
handleConnectionException in class DruidAbstractDataSourceSQLExceptionpublic long getRecycleErrorCount()
public void clearStatementCache()
throws SQLException
clearStatementCache in interface DruidDataSourceMBeanSQLExceptionpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic void registerMbean()
public void unregisterMbean()
public boolean isMbeanRegistered()
public Connection getConnection(String username, String password) throws SQLException
getConnection in interface DataSourceSQLExceptionpublic long getCreateCount()
getCreateCount in interface DruidAbstractDataSourceMBeanpublic long getDestroyCount()
getDestroyCount in interface DruidAbstractDataSourceMBeanpublic long getConnectCount()
getConnectCount in interface DruidAbstractDataSourceMBeanpublic long getCloseCount()
getCloseCount in interface DruidAbstractDataSourceMBeanpublic long getConnectErrorCount()
getConnectErrorCount in interface DruidAbstractDataSourceMBeanpublic int getPoolingCount()
getPoolingCount in interface DruidAbstractDataSourceMBeanpublic int getPoolingPeak()
getPoolingPeak in interface DruidDataSourceMBeanpublic Date getPoolingPeakTime()
getPoolingPeakTime in interface DruidDataSourceMBeanpublic long getRecycleCount()
getRecycleCount in interface DruidAbstractDataSourceMBeanpublic int getActiveCount()
getActiveCount in interface DruidAbstractDataSourceMBeanpublic void logStats()
public DruidDataSourceStatValue getStatValueAndReset()
public long getRemoveAbandonedCount()
getRemoveAbandonedCount in interface DruidAbstractDataSourceMBeanpublic int removeAbandoned()
removeAbandoned in interface DruidDataSourceMBeanpublic Reference getReference() throws NamingException
getReference in interface ReferenceableNamingExceptionpublic List<String> getFilterClassNames()
getFilterClassNames in interface DruidAbstractDataSourceMBeanpublic int getRawDriverMajorVersion()
getRawDriverMajorVersion in interface DruidAbstractDataSourceMBeangetRawDriverMajorVersion in class DruidAbstractDataSourcepublic int getRawDriverMinorVersion()
getRawDriverMinorVersion in interface DruidAbstractDataSourceMBeangetRawDriverMinorVersion in class DruidAbstractDataSourcepublic String getProperties()
getProperties in interface DruidAbstractDataSourceMBeangetProperties in class DruidAbstractDataSourcepublic void shrink()
shrink in interface DruidDataSourceMBeanpublic void shrink(boolean checkTime)
public void shrink(boolean checkTime,
boolean keepAlive)
public int getWaitThreadCount()
getWaitThreadCount in interface DruidDataSourceMBeanpublic long getNotEmptyWaitCount()
getNotEmptyWaitCount in interface DruidDataSourceMBeanpublic int getNotEmptyWaitThreadCount()
getNotEmptyWaitThreadCount in interface DruidDataSourceMBeanpublic int getNotEmptyWaitThreadPeak()
public long getNotEmptySignalCount()
getNotEmptySignalCount in interface DruidDataSourceMBeanpublic long getNotEmptyWaitMillis()
getNotEmptyWaitMillis in interface DruidDataSourceMBeanpublic long getNotEmptyWaitNanos()
getNotEmptyWaitNanos in interface DruidDataSourceMBeanpublic int getLockQueueLength()
getLockQueueLength in interface DruidDataSourceMBeanpublic int getActivePeak()
getActivePeak in interface DruidDataSourceMBeangetActivePeak in class DruidAbstractDataSourcepublic Date getActivePeakTime()
getActivePeakTime in interface DruidDataSourceMBeanpublic String dump()
dump in interface DruidDataSourceMBeanpublic long getErrorCount()
getErrorCount in interface DruidDataSourceMBeanpublic void logTransaction(TransactionInfo info)
logTransaction in class DruidAbstractDataSourcepublic String getVersion()
getVersion in interface DruidDataSourceMBeanpublic JdbcDataSourceStat getDataSourceStat()
getDataSourceStat in interface DataSourceProxypublic Object clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic 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 WrapperisWrapperFor in class WrapperAdapterpublic <T> T unwrap(Class<T> iface)
unwrap in interface Wrapperunwrap in class WrapperAdapterpublic boolean isLogDifferentThread()
public void setLogDifferentThread(boolean logDifferentThread)
public DruidPooledConnection tryGetConnection() throws SQLException
SQLExceptionpublic int fill()
throws SQLException
fill in interface DruidDataSourceMBeanSQLExceptionpublic int fill(int toCount)
throws SQLException
fill in interface DruidDataSourceMBeanSQLExceptionpublic boolean isFull()
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister in interface MBeanRegistrationExceptionpublic void postRegister(Boolean registrationDone)
postRegister in interface MBeanRegistrationpublic void preDeregister()
throws Exception
preDeregister in interface MBeanRegistrationExceptionpublic void postDeregister()
postDeregister in interface MBeanRegistrationpublic boolean isClosed()
Copyright © 2013–2018 Alibaba Group. All rights reserved.