db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fco. Rubén Calle Aparicio <ruben.ca...@coverlink.com>
Subject Problem with connections to two data sources
Date Fri, 26 Sep 2003 09:45:52 GMT
Hi,

I want to connect to multiple databases using a single
torque.properties.file.
I  have 2 schemas asociated to each database: default_schema.xml and db2_
schema.xml
The databases (db1, db2)  running on SQL Server 2000 in the same machine
My Torque version is Torque 3.0-b3 on Resin 2.1.8
My torque.properties file is like:

### start torque.properties file:
torque.database.default=default
torque.database.default.adapter=mssql

### Jetspeed Microsoft SQL
torque.dsfactory.default.connection.driver
=com.microsoft.jdbc.sqlserver.SQLServerDriver
torque.dsfactory.default.connection.url
=jdbc:microsoft:sqlserver://<DATABASE -
IP>:1433;databaseName=db1;SelectMethod=cursor
torque.dsfactory.default.connection.user =  ****
torque.dsfactory.default.connection.password = ****
torque.dsfactory.default.factory=org.apache.torque.dsfactory.TorqueDataSourc
eFactory

# The number of database connections to cache per ConnectionPool instance
torque.dsfactory.default.pool.defaultMaxConnections=10
torque.dsfactory.default.pool.maxExpiryTime=3600
torque.dsfactory.default.pool.connectionWaitTimeout=10

### The Other Database (db2)
torque.dsfactory.db2.connection.driver
=com.microsoft.jdbc.sqlserver.SQLServerDriver
torque.dsfactory.db2.connection.url =jdbc:microsoft:sqlserver://<DATABASE -
IP>:1433;databaseName=db2;SelectMethod=cursor
torque.dsfactory.db2.connection.user =  ****
torque.dsfactory.db2.connection.password = ****
torque.dsfactory.db2.factory=org.apache.torque.dsfactory.TorqueDataSourceFac
tory

# The number of database connections to cache per ConnectionPool instance
(specified per database)
torque.dsfactory.db2.pool.defaultMaxConnections=10
torque.dsfactory.db2.pool.maxExpiryTime=3600
torque.dsfactory.db2.pool.connectionWaitTimeout=10
### end torque.properties file

The problem is that i can connect to db1 and to db2 BUT not at the same
time, is to say, if i define a connection for db1, i can connect
to db1 without problems but when i try to connect to db2 with ANOTHER
connection Torque uses the old connection (db1 conn); and if i
define a connection for db2, i can connect to db2 without problems but when
i try to connect to db1 with ANOTHER connection Torque uses the old
connection (db2 conn); !?!

The code is:

Connection connDB1=Torque.getConnection("default"); or Connection
connDB1=Torque.getConnection();
//....
//List rows= Tabledb1Peer.doSelect(criteria,connDB1);
//...
// Conection with db1 ok - i can select rows from db1
connDB1.close();

Connection connDB2=Torque.getConnection("db2");
//....
//List rows= Tabledb2Peer.doSelect(criteria,connDB2);
//...
// ERROR:: The conection holds on db1 !!!! and viceversa!!


Connection connDB2=Torque.getConnection("db2");
//....
//List rows= Tabledb2Peer.doSelect(criteria,connDB2);
//...
// Conection with db2 ok - i can select rows from db2

connDB2.close();
Connection connDB1=Torque.getConnection("default");
//....
//List rows= Tabledb1Peer.doSelect(criteria,connDB1);
//...
// ERROR:: The conection holds on db2 .....

What is wrong!?? How can i switch from one connection to other properly ?¿?¿

Thank You Very Much








---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message