dirkv 2004/03/07 07:26:38
Modified: dbcp/src/java/org/apache/commons/dbcp PoolingConnection.java
Log:
Bugzilla Bug 27246: PreparedStatement cache should be different depending on the
Catalog
(Ludovic Dubost)
Revision Changes Path
1.14 +32 -5
jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/PoolingConnection.java
Index: PoolingConnection.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/PoolingConnection.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- PoolingConnection.java 28 Feb 2004 12:18:17 -0000 1.13
+++ PoolingConnection.java 7 Mar 2004 15:26:38 -0000 1.14
@@ -147,14 +147,22 @@
* Create a PStmtKey for the given arguments.
*/
protected Object createKey(String sql, int resultSetType, int
resultSetConcurrency) {
- return new PStmtKey(normalizeSQL(sql),resultSetType,resultSetConcurrency);
+ String catalog = null;
+ try {
+ catalog = getCatalog();
+ } catch (Exception e) {}
+ return new PStmtKey(normalizeSQL(sql), catalog, resultSetType,
resultSetConcurrency);
}
/**
* Create a PStmtKey for the given arguments.
*/
protected Object createKey(String sql) {
- return new PStmtKey(normalizeSQL(sql));
+ String catalog = null;
+ try {
+ catalog = getCatalog();
+ } catch (Exception e) {}
+ return new PStmtKey(normalizeSQL(sql), catalog);
}
/**
@@ -242,21 +250,35 @@
protected String _sql = null;
protected Integer _resultSetType = null;
protected Integer _resultSetConcurrency = null;
-
+ protected String _catalog = null;
+
PStmtKey(String sql) {
_sql = sql;
}
+ PStmtKey(String sql, String catalog) {
+ _sql = sql;
+ _catalog = catalog;
+ }
+
PStmtKey(String sql, int resultSetType, int resultSetConcurrency) {
_sql = sql;
_resultSetType = new Integer(resultSetType);
_resultSetConcurrency = new Integer(resultSetConcurrency);
}
+ PStmtKey(String sql, String catalog, int resultSetType, int
resultSetConcurrency) {
+ _sql = sql;
+ _catalog = catalog;
+ _resultSetType = new Integer(resultSetType);
+ _resultSetConcurrency = new Integer(resultSetConcurrency);
+ }
+
public boolean equals(Object that) {
try {
PStmtKey key = (PStmtKey)that;
return( ((null == _sql && null == key._sql) ||
_sql.equals(key._sql)) &&
+ ((null == _catalog && null == key._catalog) ||
_catalog.equals(key._catalog)) &&
((null == _resultSetType && null == key._resultSetType) ||
_resultSetType.equals(key._resultSetType)) &&
((null == _resultSetConcurrency && null ==
key._resultSetConcurrency) || _resultSetConcurrency.equals(key._resultSetConcurrency))
);
@@ -268,13 +290,18 @@
}
public int hashCode() {
- return(null == _sql ? 0 : _sql.hashCode());
+ if (_catalog==null)
+ return(null == _sql ? 0 : _sql.hashCode());
+ else
+ return(null == _sql ? _catalog.hashCode() : (_catalog +
_sql).hashCode());
}
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("PStmtKey: sql=");
buf.append(_sql);
+ buf.append(", catalog=");
+ buf.append(_catalog);
buf.append(", resultSetType=");
buf.append(_resultSetType);
buf.append(", resultSetConcurrency=");
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]