mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
C3P0Adapter
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@680 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -113,7 +113,7 @@ public abstract class DruidAbstractDataSource implements DruidAbstractDataSource
|
||||
private boolean testOnReturn = DEFAULT_TEST_ON_RETURN;
|
||||
private boolean testWhileIdle = DEFAULT_WHILE_IDLE;
|
||||
protected boolean poolPreparedStatements = false;
|
||||
protected int maxPoolPreparedStatementPerConnectionSize = -1;
|
||||
protected int maxPoolPreparedStatementPerConnectionSize = -1;
|
||||
|
||||
protected boolean inited = false;
|
||||
|
||||
@@ -166,6 +166,16 @@ public abstract class DruidAbstractDataSource implements DruidAbstractDataSource
|
||||
|
||||
protected Date createdTime;
|
||||
|
||||
protected int connectionErrorRetryAttempts = 30;
|
||||
|
||||
public int getConnectionErrorRetryAttempts() {
|
||||
return connectionErrorRetryAttempts;
|
||||
}
|
||||
|
||||
public void setConnectionErrorRetryAttempts(int connectionErrorRetryAttempts) {
|
||||
this.connectionErrorRetryAttempts = connectionErrorRetryAttempts;
|
||||
}
|
||||
|
||||
public long getDupCloseCount() {
|
||||
return dupCloseCount.get();
|
||||
}
|
||||
@@ -269,7 +279,7 @@ public abstract class DruidAbstractDataSource implements DruidAbstractDataSource
|
||||
public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
|
||||
this.removeAbandonedTimeoutMillis = removeAbandonedTimeout * 1000;
|
||||
}
|
||||
|
||||
|
||||
public void setRemoveAbandonedTimeoutMillis(int removeAbandonedTimeoutMillis) {
|
||||
this.removeAbandonedTimeoutMillis = removeAbandonedTimeoutMillis;
|
||||
}
|
||||
|
||||
@@ -653,7 +653,6 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
public void run() {
|
||||
initedLatch.countDown();
|
||||
|
||||
final int MAX_ERRRO_TRY = 3;
|
||||
int errorCount = 0;
|
||||
for (;;) {
|
||||
// addLast
|
||||
@@ -699,7 +698,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
|
||||
errorCount++;
|
||||
|
||||
if (errorCount > MAX_ERRRO_TRY && timeBetweenConnectErrorMillis > 0) {
|
||||
if (errorCount > connectionErrorRetryAttempts && timeBetweenConnectErrorMillis > 0) {
|
||||
try {
|
||||
Thread.sleep(timeBetweenConnectErrorMillis);
|
||||
} catch (InterruptedException e1) {
|
||||
|
||||
@@ -105,11 +105,11 @@ public class DruidDataSourceC3P0Adapter implements DataSource, DruidDataSourceC3
|
||||
}
|
||||
|
||||
public int getCheckoutTimeout() {
|
||||
return (int) dataSource.getMaxWait();
|
||||
return (int) dataSource.getMaxWait() / 1000;
|
||||
}
|
||||
|
||||
public void setCheckoutTimeout(int checkoutTimeout) {
|
||||
dataSource.setMaxWait(checkoutTimeout);
|
||||
dataSource.setMaxWait(checkoutTimeout * 1000);
|
||||
}
|
||||
|
||||
public boolean isAutoCommitOnClose() {
|
||||
@@ -224,6 +224,46 @@ public class DruidDataSourceC3P0Adapter implements DataSource, DruidDataSourceC3
|
||||
dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxStatementsPerConnection);
|
||||
}
|
||||
|
||||
public int getMaxStatements() {
|
||||
return dataSource.getMaxOpenPreparedStatements();
|
||||
}
|
||||
|
||||
public void setMaxStatements(int maxStatements) {
|
||||
dataSource.setMaxOpenPreparedStatements(maxStatements);
|
||||
}
|
||||
|
||||
public int getUnreturnedConnectionTimeout() {
|
||||
return dataSource.getRemoveAbandonedTimeout();
|
||||
}
|
||||
|
||||
public void setUnreturnedConnectionTimeout(int unreturnedConnectionTimeout) {
|
||||
dataSource.setRemoveAbandonedTimeout(unreturnedConnectionTimeout);
|
||||
}
|
||||
|
||||
public boolean isDebugUnreturnedConnectionStackTraces() {
|
||||
return dataSource.isLogAbandoned();
|
||||
}
|
||||
|
||||
public void setDebugUnreturnedConnectionStackTraces(boolean debugUnreturnedConnectionStackTraces) {
|
||||
dataSource.setLogAbandoned(debugUnreturnedConnectionStackTraces);
|
||||
}
|
||||
|
||||
public int getAcquireRetryAttempts() {
|
||||
return dataSource.getConnectionErrorRetryAttempts();
|
||||
}
|
||||
|
||||
public void setAcquireRetryAttempts(int acquireRetryAttempts) {
|
||||
dataSource.setConnectionErrorRetryAttempts(acquireRetryAttempts);
|
||||
}
|
||||
|
||||
public int getAcquireRetryDelay() {
|
||||
return (int) (dataSource.getTimeBetweenConnectErrorMillis() / 1000L);
|
||||
}
|
||||
|
||||
public void setAcquireRetryDelay(int acquireRetryDelay) {
|
||||
dataSource.setTimeBetweenConnectErrorMillis(((long) acquireRetryDelay) * 1000);
|
||||
}
|
||||
|
||||
// /////////////////
|
||||
|
||||
@Override
|
||||
@@ -263,24 +303,11 @@ public class DruidDataSourceC3P0Adapter implements DataSource, DruidDataSourceC3
|
||||
private int maxIdleTimeExcessConnections;
|
||||
private int maxConnectionAge;
|
||||
private String connectionCustomizerClassName;
|
||||
private int unreturnedConnectionTimeout;
|
||||
private boolean debugUnreturnedConnectionStackTraces;
|
||||
private String factoryClassLocation;
|
||||
private int acquireIncrement = 1;
|
||||
private int acquireRetryDelay;
|
||||
private int acquireRetryAttempts;
|
||||
|
||||
private String connectionTesterClassName;
|
||||
private String automaticTestTable;
|
||||
private int maxStatements;
|
||||
|
||||
public int getMaxStatements() {
|
||||
return maxStatements;
|
||||
}
|
||||
|
||||
public void setMaxStatements(int maxStatements) {
|
||||
this.maxStatements = maxStatements;
|
||||
}
|
||||
|
||||
public String getConnectionTesterClassName() {
|
||||
return connectionTesterClassName;
|
||||
@@ -356,22 +383,6 @@ public class DruidDataSourceC3P0Adapter implements DataSource, DruidDataSourceC3
|
||||
this.connectionCustomizerClassName = connectionCustomizerClassName;
|
||||
}
|
||||
|
||||
public int getUnreturnedConnectionTimeout() {
|
||||
return unreturnedConnectionTimeout;
|
||||
}
|
||||
|
||||
public void setUnreturnedConnectionTimeout(int unreturnedConnectionTimeout) {
|
||||
this.unreturnedConnectionTimeout = unreturnedConnectionTimeout;
|
||||
}
|
||||
|
||||
public boolean isDebugUnreturnedConnectionStackTraces() {
|
||||
return debugUnreturnedConnectionStackTraces;
|
||||
}
|
||||
|
||||
public void setDebugUnreturnedConnectionStackTraces(boolean debugUnreturnedConnectionStackTraces) {
|
||||
this.debugUnreturnedConnectionStackTraces = debugUnreturnedConnectionStackTraces;
|
||||
}
|
||||
|
||||
public String getFactoryClassLocation() {
|
||||
return factoryClassLocation;
|
||||
}
|
||||
@@ -388,22 +399,6 @@ public class DruidDataSourceC3P0Adapter implements DataSource, DruidDataSourceC3
|
||||
this.acquireIncrement = acquireIncrement;
|
||||
}
|
||||
|
||||
public int getAcquireRetryAttempts() {
|
||||
return acquireRetryAttempts;
|
||||
}
|
||||
|
||||
public void setAcquireRetryAttempts(int acquireRetryAttempts) {
|
||||
this.acquireRetryAttempts = acquireRetryAttempts;
|
||||
}
|
||||
|
||||
public int getAcquireRetryDelay() {
|
||||
return acquireRetryDelay;
|
||||
}
|
||||
|
||||
public void setAcquireRetryDelay(int acquireRetryDelay) {
|
||||
this.acquireRetryDelay = acquireRetryDelay;
|
||||
}
|
||||
|
||||
public String getOverrideDefaultUser() {
|
||||
return overrideDefaultUser;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user