You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Dave Everson <dj...@mygolftrac.com> on 2002/02/04 03:40:38 UTC

Error using Multiple Databases and Torque

We are using the OM classes generated via standalone Torque (built from
CVS Jan29th).  We have two schemas that point to two databases (rcmwf
and smartdata).  In testing our code we have discovered that we are able
to read and insert/update data in the first database (rcmwf).  However,
with the second database (smartdata) we can only read data.  Whenever we
attempt to perform an insert with the second database, we get a Null
Pointer Exception. Unfortunately we don't get any more information than
this. Attached is a portion of the Torque.properties configuration file.


Does anybody know what might be causing these exceptions?


Portion of the .properties file:

torque.database.default=rcmwf

torque.database.rcmwf.driver=org.gjt.mm.mysql.Driver
torque.database.rcmwf.url=jdbc:mysql://localhost:3306/rcmwf
torque.database.rcmwf.username=
torque.database.rcmwf.password=
				   
torque.database.smartclaim.driver=org.gjt.mm.mysql.Driver
torque.database.smartclaim.url=jdbc:mysql://localhost:3306/smartdata
torque.database.smartclaim.username=
torque.database.smartclaim.password=

# The number of database connections to cache per ConnectionPool 
# instance (specified per database).

torque.database.rcmwf.maxConnections=80
torque.database.smartclaim.maxConnections=80

# The amount of time (in milliseconds) that database connections will be
# cached (specified per database).
#
# Default: one hour = 60 * 60 * 1000

torque.database.rcmwf.expiryTime=3600000
torque.database.smartclaim.expiryTime=3600000

# The amount of time (in milliseconds) a connection request will have to
wait
# before a time out occurs and an error is thrown.
#
# Default: ten seconds = 10 * 1000

torque.database.rcmwf.connectionWaitTimeout=10000
torque.database.smartclaim.connectionWaitTimeout=10000

# The interval (in milliseconds) between which the PoolBrokerService
logs 
# the status of it's ConnectionPools.
#
# Default: No logging = 0 = 0 * 1000

torque.database.logInterval=10




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Error using Multiple Databases and Torque

Posted by Dave Everson <dj...@mygolftrac.com>.
Thanks for your feedback.  To answer your questions:

1.  I am using MySQL's auto increment to assign primary keys.  However,
I did create the ID table in both databases just to be on the safe side.

2.  When actually calling the same method, I use
Claim.save("smartdata");  It still does not work. 

-----Original Message-----
From: Steve [mailto:turbine_user@knology.net] 
Sent: Sunday, February 03, 2002 11:29 PM
To: Turbine Users List
Subject: RE: Error using Multiple Databases and Torque

Dave:

I can think of two things.  First, if you are using the ID Broker
service
but do not have an ID_TABLE in both dbs, you may be trying to save a
record
with a null PK, which would probably give you the NPE.

Secondly, (and let me caveat this with I've never used standalone
Torque)
but if the config file is like TR.props, (which you'd think it would be)
you
may be mis-using the "default" tag.  In TR.props, the "default" db is
the db
that Turbine will use when you don't specify a database moniker to the
getConnection calls.

e.g. dbConn = TurbineDB.getConnection() -- no parameters
dbConn = TurbineDB.getConnection("db2") -- use db2 instead of the
default.

In your TR.props file you'd specify two databases parameter lists,
thusly

## Refers to db1
database.default.driver=org.gjt.mm.mysql.Driver
database.default.url=jdbc:mysql://127.0.0.1/db1
database.default.username=
database.default.password=
database.default.maxConnections=9
database.default.expiryTime=3600000

## Refers to db2
database.soc.driver=org.gjt.mm.mysql.Driver
database.soc.url=jdbc:mysql://127.0.0.1/db2
database.soc.username=
database.soc.password=
database.soc.maxConnections=9
database.soc.expiryTime=3600000

I dunno if the Torque.props file is identical or not, but if so, maybe
the
above style would work.  Hope this helps.

Steve



-----Original Message-----
From: Dave Everson [mailto:djeverson@mygolftrac.com]
Sent: Sunday, February 03, 2002 8:41 PM
To: 'Turbine Users List'
Subject: Error using Multiple Databases and Torque


We are using the OM classes generated via standalone Torque (built from
CVS Jan29th).  We have two schemas that point to two databases (rcmwf
and smartdata).  In testing our code we have discovered that we are able
to read and insert/update data in the first database (rcmwf).  However,
with the second database (smartdata) we can only read data.  Whenever we
attempt to perform an insert with the second database, we get a Null
Pointer Exception. Unfortunately we don't get any more information than
this. Attached is a portion of the Torque.properties configuration file.


Does anybody know what might be causing these exceptions?


Portion of the .properties file:

torque.database.default=rcmwf

torque.database.rcmwf.driver=org.gjt.mm.mysql.Driver
torque.database.rcmwf.url=jdbc:mysql://localhost:3306/rcmwf
torque.database.rcmwf.username=
torque.database.rcmwf.password=

torque.database.smartclaim.driver=org.gjt.mm.mysql.Driver
torque.database.smartclaim.url=jdbc:mysql://localhost:3306/smartdata
torque.database.smartclaim.username=
torque.database.smartclaim.password=

# The number of database connections to cache per ConnectionPool
# instance (specified per database).

torque.database.rcmwf.maxConnections=80
torque.database.smartclaim.maxConnections=80

# The amount of time (in milliseconds) that database connections will be
# cached (specified per database).
#
# Default: one hour = 60 * 60 * 1000

torque.database.rcmwf.expiryTime=3600000
torque.database.smartclaim.expiryTime=3600000

# The amount of time (in milliseconds) a connection request will have to
wait
# before a time out occurs and an error is thrown.
#
# Default: ten seconds = 10 * 1000

torque.database.rcmwf.connectionWaitTimeout=10000
torque.database.smartclaim.connectionWaitTimeout=10000

# The interval (in milliseconds) between which the PoolBrokerService
logs
# the status of it's ConnectionPools.
#
# Default: No logging = 0 = 0 * 1000

torque.database.logInterval=10




--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Error using Multiple Databases and Torque

Posted by Steve <tu...@knology.net>.
Dave:

I can think of two things.  First, if you are using the ID Broker service
but do not have an ID_TABLE in both dbs, you may be trying to save a record
with a null PK, which would probably give you the NPE.

Secondly, (and let me caveat this with I've never used standalone Torque)
but if the config file is like TR.props, (which you'd think it would be) you
may be mis-using the "default" tag.  In TR.props, the "default" db is the db
that Turbine will use when you don't specify a database moniker to the
getConnection calls.

e.g. dbConn = TurbineDB.getConnection() -- no parameters
dbConn = TurbineDB.getConnection("db2") -- use db2 instead of the default.

In your TR.props file you'd specify two databases parameter lists, thusly

## Refers to db1
database.default.driver=org.gjt.mm.mysql.Driver
database.default.url=jdbc:mysql://127.0.0.1/db1
database.default.username=
database.default.password=
database.default.maxConnections=9
database.default.expiryTime=3600000

## Refers to db2
database.soc.driver=org.gjt.mm.mysql.Driver
database.soc.url=jdbc:mysql://127.0.0.1/db2
database.soc.username=
database.soc.password=
database.soc.maxConnections=9
database.soc.expiryTime=3600000

I dunno if the Torque.props file is identical or not, but if so, maybe the
above style would work.  Hope this helps.

Steve



-----Original Message-----
From: Dave Everson [mailto:djeverson@mygolftrac.com]
Sent: Sunday, February 03, 2002 8:41 PM
To: 'Turbine Users List'
Subject: Error using Multiple Databases and Torque


We are using the OM classes generated via standalone Torque (built from
CVS Jan29th).  We have two schemas that point to two databases (rcmwf
and smartdata).  In testing our code we have discovered that we are able
to read and insert/update data in the first database (rcmwf).  However,
with the second database (smartdata) we can only read data.  Whenever we
attempt to perform an insert with the second database, we get a Null
Pointer Exception. Unfortunately we don't get any more information than
this. Attached is a portion of the Torque.properties configuration file.


Does anybody know what might be causing these exceptions?


Portion of the .properties file:

torque.database.default=rcmwf

torque.database.rcmwf.driver=org.gjt.mm.mysql.Driver
torque.database.rcmwf.url=jdbc:mysql://localhost:3306/rcmwf
torque.database.rcmwf.username=
torque.database.rcmwf.password=

torque.database.smartclaim.driver=org.gjt.mm.mysql.Driver
torque.database.smartclaim.url=jdbc:mysql://localhost:3306/smartdata
torque.database.smartclaim.username=
torque.database.smartclaim.password=

# The number of database connections to cache per ConnectionPool
# instance (specified per database).

torque.database.rcmwf.maxConnections=80
torque.database.smartclaim.maxConnections=80

# The amount of time (in milliseconds) that database connections will be
# cached (specified per database).
#
# Default: one hour = 60 * 60 * 1000

torque.database.rcmwf.expiryTime=3600000
torque.database.smartclaim.expiryTime=3600000

# The amount of time (in milliseconds) a connection request will have to
wait
# before a time out occurs and an error is thrown.
#
# Default: ten seconds = 10 * 1000

torque.database.rcmwf.connectionWaitTimeout=10000
torque.database.smartclaim.connectionWaitTimeout=10000

# The interval (in milliseconds) between which the PoolBrokerService
logs
# the status of it's ConnectionPools.
#
# Default: No logging = 0 = 0 * 1000

torque.database.logInterval=10




--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>