public class DruidDataSource extends DruidAbstractDataSource implements DruidDataSourceMBean, ManagedDataSource, Referenceable, Closeable, Cloneable, ConnectionPoolDataSource, MBeanRegistration
| 限定符和类型 | 类和说明 |
|---|---|
class |
DruidDataSource.CreateConnectionTask |
class |
DruidDataSource.CreateConnectionThread |
class |
DruidDataSource.DestroyConnectionThread |
class |
DruidDataSource.DestroyTask |
class |
DruidDataSource.LogStatsThread |
DruidAbstractDataSource.PhysicalConnectionInfoaccessToUnderlyingConnectionAllowed, activeConnectionLock, activeConnections, breakAfterAcquireFailure, cachedPreparedStatementCount, cachedPreparedStatementCountUpdater, cachedPreparedStatementDeleteCount, cachedPreparedStatementDeleteCountUpdater, cachedPreparedStatementHitCount, cachedPreparedStatementHitCountUpdater, cachedPreparedStatementMissCount, cachedPreparedStatementMissCountUpdater, closedPreparedStatementCount, closedPreparedStatementCountUpdater, commitCount, commitCountUpdater, connectionErrorRetryAttempts, connectionIdSeed, connectionIdSeedUpdater, connectionInitSqls, connectProperties, createCount, createCountUpdater, createdTime, createError, createErrorCount, createErrorCountUpdater, createScheduler, createStartNanos, createStartNanosUpdater, createTimespan, creatingCount, creatingCountUpdater, dbType, 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, defaultAutoCommit, defaultCatalog, defaultReadOnly, defaultTransactionIsolation, destroyCount, destroyCountUpdater, destroyScheduler, directCreateCount, directCreateCountUpdater, driver, driverClass, driverClassLoader, dupCloseCount, dupCloseCountUpdater, empty, errorCount, errorCountUpdater, exceptionSorter, executeBatchCount, executeBatchCountUpdater, executeCount, executeCountUpdater, executeQueryCount, executeQueryCountUpdater, executeUpdateCount, executeUpdateCountUpdater, failContinuous, failContinuousTimeMillis, failContinuousTimeMillisUpdater, failContinuousUpdater, failFast, fatalErrorCount, fatalErrorCountLastShrink, filters, id, inited, initedTime, initExceptionThrow, initGlobalVariants, initialSize, initVariants, isMySql, isOracle, jdbcUrl, keepAliveBetweenTimeMillis, lastCreateError, lastCreateErrorTimeMillis, lastCreateStartTimeMillis, lastError, lastErrorTimeMillis, lastFatalError, lastFatalErrorSql, lastFatalErrorTimeMillis, lock, logAbandoned, logWriter, maxActive, maxCreateTaskCount, maxEvictableIdleTimeMillis, maxIdle, maxOpenPreparedStatements, maxPoolPreparedStatementPerConnectionSize, maxWait, maxWaitThreadCount, metaDataIdSeed, metaDataIdSeedUpdater, minEvictableIdleTimeMillis, minIdle, name, notEmpty, notFullTimeoutRetryCount, numTestsPerEvictionRun, onFatalError, onFatalErrorMaxActive, password, passwordCallback, phyMaxUseCount, phyTimeoutMillis, poolPreparedStatements, preparedStatementCount, preparedStatementCountUpdater, PRESENT, queryTimeout, removeAbandoned, removeAbandonedTimeoutMillis, resultSetIdSeed, resultSetIdSeedUpdater, rollbackCount, rollbackCountUpdater, sharePreparedStatements, startTransactionCount, startTransactionCountUpdater, statementIdSeed, statementIdSeedUpdater, statLogger, testOnBorrow, testOnReturn, testWhileIdle, timeBetweenConnectErrorMillis, timeBetweenEvictionRunsMillis, timeBetweenLogStatsMillis, transactionHistogram, transactionIdSeed, transactionIdSeedUpdater, transactionQueryTimeout, transactionThresholdMillis, useOracleImplicitCache, userCallback, username, validationQuery, validationQueryTimeout, validConnectionChecker| 构造器和说明 |
|---|
DruidDataSource() |
DruidDataSource(boolean fairLock) |
addConnectionProperty, addFilters, clearFilters, cloneTo, 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, getKeepAliveBetweenTimeMillis, 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, initStatement, isAccessToUnderlyingConnectionAllowed, isAsyncCloseConnectionEnable, isBreakAfterAcquireFailure, isClearFiltersEnable, isDefaultAutoCommit, isDupCloseLogEnable, isFailContinuous, isFailFast, isInited, isInitExceptionThrow, isInitGlobalVariants, isInitVariants, isLogAbandoned, isOnFatalError, isOracle, isPoolPreparedStatements, isRemoveAbandoned, isSharePreparedStatements, isTestOnBorrow, isTestOnReturn, isTestWhileIdle, isUseLocalSessionState, isUseOracleImplicitCache, isUseUnfairLock, setAccessToUnderlyingConnectionAllowed, setAsyncCloseConnectionEnable, setBreakAfterAcquireFailure, setClearFiltersEnable, setConnectionErrorRetryAttempts, setConnectionInitSqls, setConnectionProperties, setCreateError, setCreateScheduler, setDbType, setDefaultAutoCommit, setDefaultCatalog, setDefaultReadOnly, setDefaultTransactionIsolation, setDestroyScheduler, setDriver, setDriverClassLoader, setDriverClassName, setDupCloseLogEnable, setExceptionSorter, setExceptionSorter, setExceptionSorterClassName, setFailContinuous, setFailFast, setFilters, setInitExceptionThrow, setInitGlobalVariants, setInitialSize, setInitVariants, setKeepAliveBetweenTimeMillis, 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, testConnectionInternal, testConnectionInternal, validateConnectiongetObjectName, getTimeBetweenLogStatsMillis, getUrl, 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, getUsername, getValidationQuery, getValidationQueryTimeout, getValidConnectionCheckerClassName, isBreakAfterAcquireFailure, isDefaultAutoCommit, isLogAbandoned, isPoolPreparedStatements, isRemoveAbandoned, isSharePreparedStatements, isTestOnBorrow, isTestOnReturn, isTestWhileIdle, isUseOracleImplicitCache, setLogAbandoned, setMaxPoolPreparedStatementPerConnectionSize, setTestOnBorrow, setTestWhileIdle, setTransactionThresholdMillis, setUseOracleImplicitCachegetObjectName, setObjectNamegetLoginTimeout, getLogWriter, getParentLogger, setLoginTimeout, setLogWriterprivate static final Log LOG
private static final long serialVersionUID
private volatile long recycleErrorCount
private long connectCount
private long closeCount
private volatile long connectErrorCount
private long recycleCount
private long removeAbandonedCount
private long notEmptyWaitCount
private long notEmptySignalCount
private long notEmptyWaitNanos
private int keepAliveCheckCount
private int activePeak
private long activePeakTime
private int poolingPeak
private long poolingPeakTime
private volatile DruidConnectionHolder[] connections
private int poolingCount
private int activeCount
private volatile long discardCount
private int notEmptyWaitThreadCount
private int notEmptyWaitThreadPeak
private DruidConnectionHolder[] evictConnections
private DruidConnectionHolder[] keepAliveConnections
private volatile ScheduledFuture<?> destroySchedulerFuture
private DruidDataSource.DestroyTask destroyTask
private volatile Future<?> createSchedulerFuture
private DruidDataSource.CreateConnectionThread createConnectionThread
private DruidDataSource.DestroyConnectionThread destroyConnectionThread
private DruidDataSource.LogStatsThread logStatsThread
private int createTaskCount
private volatile long createTaskIdSeed
private long[] createTasks
private final CountDownLatch initedLatch
private volatile boolean enable
private boolean resetStatEnable
private volatile long resetCount
private String initStackTrace
private volatile boolean closing
private volatile boolean closed
private long closeTimeMillis
protected JdbcDataSourceStat dataSourceStat
private boolean useGlobalDataSourceStat
private boolean mbeanRegistered
public static ThreadLocal<Long> waitNanosLocal
private boolean logDifferentThread
private volatile boolean keepAlive
private boolean asyncInit
protected boolean killWhenSocketReadTimeout
protected boolean checkExecuteTime
private boolean loadSpifilterSkip
private volatile DataSourceDisableException disableException
protected static final AtomicLongFieldUpdater<DruidDataSource> recycleErrorCountUpdater
protected static final AtomicLongFieldUpdater<DruidDataSource> connectErrorCountUpdater
protected static final AtomicLongFieldUpdater<DruidDataSource> resetCountUpdater
protected static final AtomicLongFieldUpdater<DruidDataSource> createTaskIdSeedUpdater
protected String instanceKey
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 在接口中 DruidDataSourceMBeanpublic void setResetStatEnable(boolean resetStatEnable)
setResetStatEnable 在接口中 DruidDataSourceMBeanpublic long getDiscardCount()
getDiscardCount 在接口中 DruidDataSourceMBeanpublic void restart()
throws SQLException
SQLExceptionpublic void resetStat()
resetStat 在接口中 DruidDataSourceMBeanpublic long getResetCount()
getResetCount 在接口中 DruidDataSourceMBeanpublic boolean isEnable()
isEnable 在接口中 DruidDataSourceMBeanisEnable 在接口中 ManagedDataSourcepublic void setEnable(boolean enable)
setEnable 在接口中 ManagedDataSourcepublic void setPoolPreparedStatements(boolean value)
private void setPoolPreparedStatements0(boolean value)
public void setMaxActive(int maxActive)
setMaxActive 在接口中 DruidAbstractDataSourceMBeansetMaxActive 在类中 DruidAbstractDataSourcepublic void setConnectProperties(Properties properties)
public void init()
throws SQLException
SQLExceptionprivate void submitCreateTask(boolean initTask)
private boolean clearCreateTask(long taskId)
private void createAndLogThread()
protected void createAndStartDestroyThread()
protected void createAndStartCreatorThread()
private void initFromSPIServiceLoader()
ServiceLoaderprivate void initFromWrapDriverUrl()
throws SQLException
SQLExceptionprivate void addFilter(Filter filter)
filter - private void validationQueryCheck()
protected void initCheck()
throws SQLException
SQLExceptionprivate void oracleValidationQueryCheck()
private void db2ValidationQueryCheck()
private void initValidConnectionChecker()
private void initExceptionSorter()
public DruidPooledConnection getConnection() throws SQLException
getConnection 在接口中 DataSourceSQLExceptionpublic DruidPooledConnection getConnection(long maxWaitMillis) throws SQLException
SQLExceptionpublic PooledConnection getPooledConnection() throws SQLException
getPooledConnection 在接口中 ConnectionPoolDataSourceSQLExceptionpublic PooledConnection getPooledConnection(String user, String password) throws SQLException
getPooledConnection 在接口中 ConnectionPoolDataSourceSQLExceptionpublic DruidPooledConnection getConnectionDirect(long maxWaitMillis) throws SQLException
SQLExceptionpublic void discardConnection(Connection realConnection)
discardConnection 在类中 DruidAbstractDataSourcerealConnection - public void discardConnection(DruidConnectionHolder holder)
private DruidPooledConnection getConnectionInternal(long maxWait) throws SQLException
SQLExceptionpublic void handleConnectionException(DruidPooledConnection pooledConnection, Throwable t, String sql) throws SQLException
handleConnectionException 在类中 DruidAbstractDataSourceSQLExceptionprotected final void handleFatalError(DruidPooledConnection conn, SQLException error, String sql) throws SQLException
SQLExceptionprotected void recycle(DruidPooledConnection pooledConnection) throws SQLException
recycle 在类中 DruidAbstractDataSourceSQLExceptionpublic long getRecycleErrorCount()
public void clearStatementCache()
throws SQLException
clearStatementCache 在接口中 DruidDataSourceMBeanSQLExceptionpublic void close()
close 在接口中 Closeableclose 在接口中 AutoCloseablepublic void registerMbean()
public void unregisterMbean()
public boolean isMbeanRegistered()
boolean putLast(DruidConnectionHolder e, long lastActiveTimeMillis)
DruidConnectionHolder takeLast() throws InterruptedException, SQLException
private DruidConnectionHolder pollLast(long nanos) throws InterruptedException, SQLException
private final void decrementPoolingCount()
private final void incrementPoolingCount()
public Connection getConnection(String username, String password) throws SQLException
getConnection 在接口中 DataSourceSQLExceptionpublic long getCreateCount()
getCreateCount 在接口中 DruidAbstractDataSourceMBeanpublic long getDestroyCount()
getDestroyCount 在接口中 DruidAbstractDataSourceMBeanpublic long getConnectCount()
getConnectCount 在接口中 DruidAbstractDataSourceMBeanpublic long getCloseCount()
getCloseCount 在接口中 DruidAbstractDataSourceMBeanpublic long getConnectErrorCount()
public int getPoolingCount()
getPoolingCount 在接口中 DruidAbstractDataSourceMBeanpublic int getPoolingPeak()
getPoolingPeak 在接口中 DruidDataSourceMBeanpublic Date getPoolingPeakTime()
getPoolingPeakTime 在接口中 DruidDataSourceMBeanpublic long getRecycleCount()
getRecycleCount 在接口中 DruidAbstractDataSourceMBeanpublic int getActiveCount()
getActiveCount 在接口中 DruidAbstractDataSourceMBeanpublic void logStats()
public DruidDataSourceStatValue getStatValueAndReset()
public long getRemoveAbandonedCount()
protected boolean put(DruidAbstractDataSource.PhysicalConnectionInfo physicalConnectionInfo)
private boolean put(DruidConnectionHolder holder, long createTaskId)
public int removeAbandoned()
removeAbandoned 在接口中 DruidDataSourceMBeanpublic Reference getReference() throws NamingException
getReference 在接口中 ReferenceableNamingExceptionpublic int getRawDriverMajorVersion()
public int getRawDriverMinorVersion()
public String getProperties()
getProperties 在接口中 DruidAbstractDataSourceMBeangetProperties 在类中 DruidAbstractDataSourcepublic void shrink()
shrink 在接口中 DruidDataSourceMBeanpublic void shrink(boolean checkTime)
public void shrink(boolean checkTime,
boolean keepAlive)
public int getWaitThreadCount()
getWaitThreadCount 在接口中 DruidDataSourceMBeanpublic long getNotEmptyWaitCount()
getNotEmptyWaitCount 在接口中 DruidDataSourceMBeanpublic int getNotEmptyWaitThreadCount()
public int getNotEmptyWaitThreadPeak()
public long getNotEmptySignalCount()
getNotEmptySignalCount 在接口中 DruidDataSourceMBeanpublic long getNotEmptyWaitMillis()
getNotEmptyWaitMillis 在接口中 DruidDataSourceMBeanpublic long getNotEmptyWaitNanos()
getNotEmptyWaitNanos 在接口中 DruidDataSourceMBeanpublic int getLockQueueLength()
getLockQueueLength 在接口中 DruidDataSourceMBeanpublic int getActivePeak()
getActivePeak 在接口中 DruidDataSourceMBeangetActivePeak 在类中 DruidAbstractDataSourcepublic Date getActivePeakTime()
getActivePeakTime 在接口中 DruidDataSourceMBeanpublic String dump()
dump 在接口中 DruidDataSourceMBeanpublic long getErrorCount()
getErrorCount 在接口中 DruidDataSourceMBeanpublic void logTransaction(TransactionInfo info)
logTransaction 在类中 DruidAbstractDataSourcepublic String getVersion()
getVersion 在接口中 DruidDataSourceMBeanpublic JdbcDataSourceStat getDataSourceStat()
getDataSourceStat 在接口中 DataSourceProxypublic Object clone() throws CloneNotSupportedException
clone 在类中 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 在接口中 WrapperisWrapperFor 在类中 WrapperAdapterpublic <T> T unwrap(Class<T> iface)
unwrap 在接口中 Wrapperunwrap 在类中 WrapperAdapterpublic boolean isLogDifferentThread()
public void setLogDifferentThread(boolean logDifferentThread)
public DruidPooledConnection tryGetConnection() throws SQLException
SQLExceptionpublic int fill()
throws SQLException
fill 在接口中 DruidDataSourceMBeanSQLExceptionpublic int fill(int toCount)
throws SQLException
fill 在接口中 DruidDataSourceMBeanSQLExceptionprivate boolean isFillable(int toCount)
public boolean isFull()
private void emptySignal()
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception
preRegister 在接口中 MBeanRegistrationExceptionpublic void postRegister(Boolean registrationDone)
postRegister 在接口中 MBeanRegistrationpublic void preDeregister()
throws Exception
preDeregister 在接口中 MBeanRegistrationExceptionpublic void postDeregister()
postDeregister 在接口中 MBeanRegistrationpublic boolean isClosed()
public boolean isCheckExecuteTime()
public void setCheckExecuteTime(boolean checkExecuteTime)
Copyright © 2013–2019 Alibaba Group. All rights reserved.