mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
改进PreparedStatementCache
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@916 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -43,27 +43,26 @@ import com.alibaba.druid.pool.PreparedStatementPool.MethodType;
|
||||
*/
|
||||
public class PoolablePreparedStatement extends PoolableStatement implements PreparedStatement {
|
||||
|
||||
private PreparedStatement stmt;
|
||||
private final PreparedStatementKey key;
|
||||
private final String sql;
|
||||
private final PreparedStatementHolder holder;
|
||||
private final PreparedStatement stmt;
|
||||
private final String sql;
|
||||
|
||||
private int defaultMaxFieldSize;
|
||||
private int defaultMaxRows;
|
||||
private int defaultQueryTimeout;
|
||||
private int defaultFetchDirection;
|
||||
private int defaultFetchSize;
|
||||
private int currentMaxFieldSize;
|
||||
private int currentMaxRows;
|
||||
private int currentQueryTimeout;
|
||||
private int currentFetchDirection;
|
||||
private int currentFetchSize;
|
||||
private int defaultMaxFieldSize;
|
||||
private int defaultMaxRows;
|
||||
private int defaultQueryTimeout;
|
||||
private int defaultFetchDirection;
|
||||
private int defaultFetchSize;
|
||||
private int currentMaxFieldSize;
|
||||
private int currentMaxRows;
|
||||
private int currentQueryTimeout;
|
||||
private int currentFetchDirection;
|
||||
private int currentFetchSize;
|
||||
|
||||
public PoolablePreparedStatement(PoolableConnection conn, PreparedStatement stmt, PreparedStatementKey key,
|
||||
String sql) throws SQLException{
|
||||
super(conn, stmt);
|
||||
this.stmt = stmt;
|
||||
this.key = key;
|
||||
this.sql = sql;
|
||||
public PoolablePreparedStatement(PoolableConnection conn, PreparedStatementHolder holder) throws SQLException{
|
||||
super(conn, holder.getStatement());
|
||||
this.stmt = holder.getStatement();
|
||||
this.holder = holder;
|
||||
this.sql = holder.getKey().sql;
|
||||
|
||||
// Remember the defaults
|
||||
defaultMaxFieldSize = stmt.getMaxFieldSize();
|
||||
@@ -77,7 +76,11 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep
|
||||
currentFetchDirection = defaultFetchDirection;
|
||||
currentFetchSize = defaultFetchSize;
|
||||
}
|
||||
|
||||
|
||||
public PreparedStatementHolder getPreparedStatementHolder() {
|
||||
return holder;
|
||||
}
|
||||
|
||||
public void setFetchSize(int rows) throws SQLException {
|
||||
currentFetchSize = rows;
|
||||
super.setFetchSize(rows);
|
||||
@@ -108,7 +111,7 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep
|
||||
}
|
||||
|
||||
public PreparedStatementKey getKey() {
|
||||
return key;
|
||||
return holder.getKey();
|
||||
}
|
||||
|
||||
public PreparedStatement getRawPreparedStatement() {
|
||||
@@ -783,8 +786,8 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep
|
||||
|
||||
public static class PreparedStatementKey {
|
||||
|
||||
protected final String sql;
|
||||
protected final String catalog;
|
||||
private final String sql;
|
||||
private final String catalog;
|
||||
|
||||
protected final MethodType methodType;
|
||||
|
||||
@@ -822,6 +825,10 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getSql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int catalogHashCode = catalog == null ? 0 : catalog.hashCode();
|
||||
int sqlHashCode = sql.hashCode();
|
||||
|
||||
Reference in New Issue
Block a user