torque- connection error

M

marcelino

Hello,

I try out working with torque. To access the database I configured a
datasource, but I can't connect. When I call the application in the
browser I get a java.lang.NullPointerException. When I connect with
the DriverManager the application is running. But I don't know how to
config Torque using the DriverManager. Also I think it makes more
sense using the datasource. Same problems I have with struts- so I
think I make a fundamental error config the datasource but I can't get
what the hell this error is.
---------------------------------------------------------------
Some notes to the following config files:
- tom_db_test is my eclipse Projekt
- the commentet rows with the "bookmark"- propertie are generated by
torque - I guess it's the default or test projekt form torque and
replaced it with tom_db_test
---------------------------------------------------------------
These are the extracts out of the config-files:
-----------------------
build.properties:
-----------------------
torque.addGetByNameMethod = true
torque.database.driver = org.gjt.mm.mysql.Driver
torque.database.host = 127.0.0.1
torque.project = tom_db_test #my eclipse-Project
torque.addIntakeRetrievable = false
torque.database.user = test
torque.addSaveMethod = true
torque.database.url = jdbc:mysql://127.0.0.1:3306/TestDB
torque.database.password = test
torque.useManagers = false
torque.sameJavaName = false
torque.database.createUrl = jdbc:mysql://127.0.0.1:3306/mysql
torque.addTimeStamp = true
torque.basePrefix = Base
torque.complexObjectModel = true
torque.useClasspath = false
torque.database.buildUrl = jdbc:mysql://127.0.0.1:3306/TestDB
torque.targetPackage = mdpro.test
torque.database = mysql
torque.home = WEB-INF

-----------------------
Torque.properties:
-----------------------
# the number of times you use a specific database URL.
torque.defaults.pool.defaultMaxConnections = 80

# Lifetime of a connection in the pool. Defaults to one hour
torque.defaults.pool.maxExpiryTime = 3600

# Sets the driver for the data sources.
torque.defaults.connection.driver = org.gjt.mm.mysql.Driver

# Sets the URL for the datasources
#torque.defaults.connection.url = jdbc:mysql://localhost:3306/TestDB
torque.defaults.connection.url = jdbc:mysql://127.0.0.1:3306/TestDB

# Sets login and password for the data sources.
torque.defaults.connection.user = test
torque.defaults.connection.password = test

# -------------------------------------------------------------------
#
# T O R Q U E P R O P E R T I E S
#
# -------------------------------------------------------------------
# These are your database settings. Look in the
# org.apache.torque.pool.* packages for more information.
#
# The parameters to connect to the default database. You MUST
# configure these properly.
# ------------------------------------------------------------------

torque.database.default=TestDB
#torque.database.bookstore.adapter=mysql
torque.database.tom_db_test.adapter=mysql

## Using commons-dbcp
torque.dsfactory.tom_db_test.factory=org.apache.torque.dsfactory.SharedPoolDataSourceFactory
#torque.dsfactory.tom_db_test.factory=org.apache.torque.dsfactory.PerUserPoolDataSourceFactory
torque.dsfactory.tom_db_test.pool.defaultMaxActive=10
torque.dsfactory.tom_db_test.pool.testOnBorrow=true
torque.dsfactory.tom_db_test.pool.validationQuery=SELECT 1
torque.dsfactory.tom_db_test.connection.driver =
org.gjt.mm.mysql.Driver
#torque.dsfactory.tom_db_test.connection.url =
jdbc:mysql://localhost:3306/TestDB
torque.dsfactory.tom_db_test.connection.url =
jdbc:mysql://127.0.0.1:3306/TestDB
torque.dsfactory.tom_db_test.connection.user = test
torque.dsfactory.tom_db_test.connection.password = test


--------------------------------------------------------------------------------------------

-----------------------
web.xml:
-----------------------
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
---------------------------------------------------------------------------------------------

-----------------------
tom_db_test-schema.xml
-----------------------
<database name="@DATABASE_DEFAULT@"
defaultIdMethod="idBroker">
<table name="person" idMethod="native">
<column name="personID" required="true" primaryKey="true"
type="INTEGER"/>
<column name="person_name" size="50" type="VARCHAR"/>
<column name="person_strasse" size="50" type="VARCHAR"/>
<column name="person_PLZ" type="INTEGER"/>
<column name="person_ort" size="50" type="VARCHAR"/>
<column name="person_telefon" size="50" type="VARCHAR"/>
<column name="person_email" size="50" type="VARCHAR"/>
</table>
</database>



--------------------------------------------------------------
--------------------------------------------------------------
The versions are:

Tomcat: 4.1.27
eclipse: 2.1.1
torque: 3.1
torque-gen: 3.1

jars:
commons- dbcp and pool: 20030825
commons- configuration: 20030607
commons- collection: 2.1
jdbc: 2.0
mysql-connector: 2.0.14
- and a lot more jars but I think thats the most important.

If somebody can give me a hint I would be thankful

thanks in advance

marcus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top