db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henning P. Schmiedehausen" <...@intermeta.de>
Subject Strange NPEs from torque - Resolution
Date Thu, 10 Jul 2003 07:53:08 GMT
Folks, 

before you run off in various directions and try to "hack" around,
here is how to solve your NPEs.

This is not a torque problem. It's a configuration error. I stumbled
over it myself. Look at this:

Let's say you have a data source called "foo". It is using the JDBC2
pool. Then you _must_ have

torque.database.foo.adapter    = postgresql
torque.foo.connection.driver   = org.postgresql.Driver
torque.dsfactory.foo.factory   = org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory

Yes, you _must_ configure the adapter with the JDBC2 pool. If you
forget this, you get the NPEs. With the old pool, the adapter type was
automagically derived from the driver class. However, this does not
work with the JDBC2 pool.

I e.g. run this configuration with my databases:

--- cut ---
#
# Set Defaults
#
torque.defaults.pool.defaultMaxActive=30
torque.defaults.pool.testOnBorrow=true
torque.defaults.pool.validationQuery=SELECT 1

torque.defaults.connection.driver   =  org.postgresql.Driver
torque.defaults.connection.url      =  jdbc:postgresql://localhost/my-database
torque.defaults.connection.user     =  my-user
torque.defaults.connection.password =  my-password

torque.idbroker.cleverquantity=true
torque.idbroker.prefetch=true
torque.idbroker.usenewconnection=true

#
# Default Database if nothing is given
#
torque.database.default = foo

#
# FOO Datasource
#
torque.database.foo.adapter = postgresql
torque.dsfactory.foo.factory= org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory

#
# BAR Datasource
#
torque.database.bar.adapter = postgresql
torque.dsfactory.bar.factory= org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory
--- cut ---

This runs without a hitch with even the most complex criterias.

Repeat after me: If you don't set your adapter type, you will get
strange NPEs. Yes, this sucks, and it should report decent error
messages. However, it doesn't. So make sure that you _have_ your
adapter type set.

	Regards
		Henning


-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

--- Quote of the week: "It is pointless to tell people anything when
you know that they won't process the message." --- Jonathan Revusky

---------------------------------------------------------------------
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