mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed : mysql performance
This commit is contained in:
@@ -51,6 +51,11 @@ public final class ConnectionHolder {
|
||||
|
||||
private final boolean defaultAutoCommit;
|
||||
|
||||
private boolean underlyingReadOnly;
|
||||
private int underlyingHoldability;
|
||||
private int underlyingTransactionIsolation;
|
||||
private boolean underlyingAutoCommit;
|
||||
|
||||
public ConnectionHolder(DruidAbstractDataSource dataSource, Connection conn) throws SQLException{
|
||||
this.dataSource = dataSource;
|
||||
this.conn = conn;
|
||||
@@ -61,10 +66,47 @@ public final class ConnectionHolder {
|
||||
this.defaultHoldability = conn.getHoldability();
|
||||
this.defaultTransactionIsolation = conn.getTransactionIsolation();
|
||||
this.defaultAutoCommit = conn.getAutoCommit();
|
||||
|
||||
this.underlyingAutoCommit = defaultAutoCommit;
|
||||
this.underlyingHoldability = defaultHoldability;
|
||||
this.underlyingTransactionIsolation = defaultTransactionIsolation;
|
||||
this.underlyingTransactionIsolation = defaultTransactionIsolation;
|
||||
|
||||
statementPool = null;
|
||||
}
|
||||
|
||||
public boolean isUnderlyingReadOnly() {
|
||||
return underlyingReadOnly;
|
||||
}
|
||||
|
||||
public void setUnderlyingReadOnly(boolean underlyingReadOnly) {
|
||||
this.underlyingReadOnly = underlyingReadOnly;
|
||||
}
|
||||
|
||||
public int getUnderlyingHoldability() {
|
||||
return underlyingHoldability;
|
||||
}
|
||||
|
||||
public void setUnderlyingHoldability(int underlyingHoldability) {
|
||||
this.underlyingHoldability = underlyingHoldability;
|
||||
}
|
||||
|
||||
public int getUnderlyingTransactionIsolation() {
|
||||
return underlyingTransactionIsolation;
|
||||
}
|
||||
|
||||
public void setUnderlyingTransactionIsolation(int underlyingTransactionIsolation) {
|
||||
this.underlyingTransactionIsolation = underlyingTransactionIsolation;
|
||||
}
|
||||
|
||||
public boolean isUnderlyingAutoCommit() {
|
||||
return underlyingAutoCommit;
|
||||
}
|
||||
|
||||
public void setUnderlyingAutoCommit(boolean underlyingAutoCommit) {
|
||||
this.underlyingAutoCommit = underlyingAutoCommit;
|
||||
}
|
||||
|
||||
public long getLastActiveTimeMillis() {
|
||||
return lastActiveTimeMillis;
|
||||
}
|
||||
@@ -122,19 +164,19 @@ public final class ConnectionHolder {
|
||||
|
||||
public void reset() throws SQLException {
|
||||
// reset default settings
|
||||
if (conn.isReadOnly() != defaultReadOnly) {
|
||||
if (underlyingReadOnly != defaultReadOnly) {
|
||||
conn.setReadOnly(defaultReadOnly);
|
||||
}
|
||||
|
||||
if (conn.getHoldability() != defaultHoldability) {
|
||||
if (underlyingHoldability != defaultHoldability) {
|
||||
conn.setHoldability(defaultHoldability);
|
||||
}
|
||||
|
||||
if (conn.getTransactionIsolation() != defaultTransactionIsolation) {
|
||||
if (underlyingTransactionIsolation != defaultTransactionIsolation) {
|
||||
conn.setTransactionIsolation(defaultTransactionIsolation);
|
||||
}
|
||||
|
||||
if (conn.getAutoCommit() != defaultAutoCommit) {
|
||||
|
||||
if (underlyingAutoCommit != defaultAutoCommit) {
|
||||
conn.setAutoCommit(defaultAutoCommit);
|
||||
}
|
||||
|
||||
@@ -146,7 +188,7 @@ public final class ConnectionHolder {
|
||||
JdbcUtils.close(stmt);
|
||||
}
|
||||
statementTrace.clear();
|
||||
|
||||
|
||||
conn.clearWarnings();
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -91,7 +91,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
}
|
||||
|
||||
void closePoolableStatement(PoolablePreparedStatement stmt) throws SQLException {
|
||||
if (this.isClosed()) {
|
||||
if (this.holder == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -585,6 +585,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
|
||||
try {
|
||||
conn.setAutoCommit(autoCommit);
|
||||
holder.setUnderlyingAutoCommit(autoCommit);
|
||||
} catch (SQLException ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
@@ -728,6 +729,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
checkOpen();
|
||||
|
||||
conn.setReadOnly(readOnly);
|
||||
holder.setUnderlyingReadOnly(readOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -756,6 +758,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
checkOpen();
|
||||
|
||||
conn.setTransactionIsolation(level);
|
||||
holder.setUnderlyingTransactionIsolation(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -798,6 +801,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
checkOpen();
|
||||
|
||||
conn.setHoldability(holdability);
|
||||
holder.setUnderlyingHoldability(holdability);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user