kschrader 2002/08/13 09:39:09
Modified: src/java/org/apache/torque/pool TorqueClassicDataSource.java
Log:
Everything went to hell if you had multiple databases
because all of the connection pools mapped to null
in the hashmap. I've enhanced the getKey method
to fix this problem, although there's probabaly a
better way to handle this.
Revision Changes Path
1.2 +32 -4
jakarta-turbine-torque/src/java/org/apache/torque/pool/TorqueClassicDataSource.java
Index: TorqueClassicDataSource.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/pool/TorqueClassicDataSource.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TorqueClassicDataSource.java 7 Aug 2002 08:07:02 -0000 1.1
+++ TorqueClassicDataSource.java 13 Aug 2002 16:39:09 -0000 1.2
@@ -419,7 +419,15 @@
String password)
throws SQLException
{
- String key = getKey(username);
+ String key = null;
+ if (username != null)
+ {
+ key = getKey(username);
+ }
+ else
+ {
+ key =
getKey(cpds.getPooledConnection().getConnection().getMetaData().getUserName());
+ }
ConnectionPool pool = (ConnectionPool)pools.get(key);
if ( pool == null )
{
@@ -444,17 +452,37 @@
private String getKey(String suffix)
{
String key = getDataSourceName();
- if ( suffix != null )
+ if ( suffix != null && key != null)
{
key += suffix;
}
+ else if (suffix != null)
+ {
+ return suffix;
+ }
+
return key;
}
synchronized private void registerPool(String username, String password)
throws javax.naming.NamingException
{
- String key = getKey(username);
+ String key = null;
+ if (username != null)
+ {
+ key = getKey(username);
+ }
+ else
+ {
+ try
+ {
+ key =
getKey(cpds.getPooledConnection().getConnection().getMetaData().getUserName());
+ }
+ catch (SQLException e)
+ {
+ key = null;
+ }
+ }
if ( !pools.containsKey(key) )
{
ConnectionPoolDataSource cpds = this.cpds;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>