mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed : statement pool
This commit is contained in:
@@ -34,6 +34,7 @@ import java.sql.SQLException;
|
||||
import java.sql.SQLXML;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
|
||||
import com.alibaba.druid.pool.PreparedStatementPool.MethodType;
|
||||
@@ -791,7 +792,42 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep
|
||||
|
||||
protected final MethodType methodType;
|
||||
|
||||
private final int resultSetType;
|
||||
private final int resultSetConcurrency;
|
||||
private final int resultSetHoldability;
|
||||
private final int autoGeneratedKeys;
|
||||
private final int[] columnIndexes;
|
||||
private final String[] columnNames;
|
||||
|
||||
public PreparedStatementKey(String sql, String catalog, MethodType methodType) throws SQLException{
|
||||
this(sql, catalog, methodType, 0, 0, 0, 0, null, null);
|
||||
}
|
||||
|
||||
public PreparedStatementKey(String sql, String catalog, MethodType methodType, int resultSetType,
|
||||
int resultSetConcurrency) throws SQLException{
|
||||
this(sql, catalog, methodType, resultSetType, resultSetConcurrency, 0, 0, null, null);
|
||||
}
|
||||
|
||||
public PreparedStatementKey(String sql, String catalog, MethodType methodType, int resultSetType,
|
||||
int resultSetConcurrency, int resultSetHoldability) throws SQLException{
|
||||
this(sql, catalog, methodType, resultSetType, resultSetConcurrency, resultSetHoldability, 0, null, null);
|
||||
}
|
||||
|
||||
public PreparedStatementKey(String sql, String catalog, MethodType methodType, int autoGeneratedKeys) throws SQLException{
|
||||
this(sql, catalog, methodType, 0, 0, 0, autoGeneratedKeys, null, null);
|
||||
}
|
||||
|
||||
public PreparedStatementKey(String sql, String catalog, MethodType methodType, int[] columnIndexes) throws SQLException{
|
||||
this(sql, catalog, methodType, 0, 0, 0, 0, columnIndexes, null);
|
||||
}
|
||||
|
||||
public PreparedStatementKey(String sql, String catalog, MethodType methodType, String[] columnNames) throws SQLException{
|
||||
this(sql, catalog, methodType, 0, 0, 0, 0, null, columnNames);
|
||||
}
|
||||
|
||||
public PreparedStatementKey(String sql, String catalog, MethodType methodType, int resultSetType,
|
||||
int resultSetConcurrency, int resultSetHoldability, int autoGeneratedKeys,
|
||||
int[] columnIndexes, String[] columnNames) throws SQLException{
|
||||
if (sql == null) {
|
||||
throw new SQLException("sql is null");
|
||||
}
|
||||
@@ -799,6 +835,24 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep
|
||||
this.sql = sql;
|
||||
this.catalog = catalog;
|
||||
this.methodType = methodType;
|
||||
this.resultSetType = resultSetType;
|
||||
this.resultSetConcurrency = resultSetConcurrency;
|
||||
this.resultSetHoldability = resultSetHoldability;
|
||||
this.autoGeneratedKeys = autoGeneratedKeys;
|
||||
this.columnIndexes = columnIndexes;
|
||||
this.columnNames = columnNames;
|
||||
}
|
||||
|
||||
public int getResultSetType() {
|
||||
return resultSetType;
|
||||
}
|
||||
|
||||
public int getResultSetConcurrency() {
|
||||
return resultSetConcurrency;
|
||||
}
|
||||
|
||||
public int getResultSetHoldability() {
|
||||
return resultSetHoldability;
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
@@ -821,19 +875,58 @@ public class PoolablePreparedStatement extends PoolableStatement implements Prep
|
||||
if (this.methodType != that.methodType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.resultSetType != that.resultSetType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.resultSetConcurrency != that.resultSetConcurrency) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.resultSetHoldability != that.resultSetHoldability) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.autoGeneratedKeys != that.autoGeneratedKeys) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Arrays.equals(columnIndexes, that.columnIndexes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Arrays.equals(columnNames, that.columnNames)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
|
||||
result = prime * result + ((sql == null) ? 0 : sql.hashCode());
|
||||
result = prime * result + ((catalog == null) ? 0 : catalog.hashCode());
|
||||
result = prime * result + ((methodType == null) ? 0 : methodType.hashCode());
|
||||
|
||||
result = prime * result + resultSetConcurrency;
|
||||
result = prime * result + resultSetHoldability;
|
||||
result = prime * result + resultSetType;
|
||||
|
||||
result = prime * result + autoGeneratedKeys;
|
||||
|
||||
result = prime * result + Arrays.hashCode(columnIndexes);
|
||||
result = prime * result + Arrays.hashCode(columnNames);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getSql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int catalogHashCode = catalog == null ? 0 : catalog.hashCode();
|
||||
int sqlHashCode = sql.hashCode();
|
||||
|
||||
return sqlHashCode ^ catalogHashCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user