You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Catalin Constantin <ca...@bounce-software.com> on 2003/08/29 11:19:58 UTC
torque webapp dbcp pool
i want to use torque in my webapp.
my current web application uses a data sorce configured in tomcat
with DBCP.
=> i have in my server.xml the following:
<Resource name="jdbc/postgres" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/ksi">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.postgresql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:postgresql://127.0.0.1:5432/ksidevel</value>
</parameter>
<parameter>
<name>username</name>
<value>user</value>
</parameter>
<parameter>
<name>password</name>
<value>pass</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>
also in my web.xmk file
i have:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>java:comp/env/jdbc/ksi</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
in my java class that is handling the SQL request right now (queries, etc)
i get the connection with the following code:
Context ctx = new InitialContext();
if(ctx == null ) throw new Exception("There is no Context");
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/ksi");
the thing is that now i want to USE torque to make all the SQL part:
i don't want to set another connection poolling with torque.
instead, i want torque to use the already existing binding: jdbc/ksi
i suppose i have to initialize the Torque system in my InitServlet class
so i wrote the Torque.properties file and initialize it on startup of my
application.
Torque.init(getServletConfig().getServletContext().getRealPath("/WEB-INF/con
f/Torque.properties"));
what do i have to set in my Torque.properties file in order to make it work?
right now i have:
torque.database.ksi.adapter=postgresql
torque.dsfactory.ksi.jndi.path=jdbc/ksi
torque.idbroker.clever.quantity=false
torque.idbroker.prefetch=true
on startup i get the following error in the log:
2003/08/29 12:00:51 ERROR [InitServlet] - Torque Error:
java.lang.NullPointerException: There was no DataSourceFactory configured
for the connection user_password
at
org.apache.torque.TorqueInstance.getConnection(TorqueInstance.java:749)
at org.apache.torque.Torque.getConnection(Torque.java:306)
at
org.apache.torque.util.Transaction.beginOptional(Transaction.java:118)
at org.apache.torque.util.Transaction.begin(Transaction.java:100)
at
ro.dazoot.ksi.db.torque.BaseUserPassword.save(BaseUserPassword.java:1497)
at ro.dazoot.ksi.init.InitServlet.init(InitServlet.java:110)
.....
can somebody tell me, what m i doing wrong ?
can anyone point me out to some GOOD documentation (except the one from
db.apache.org) or some GOOD webapp examples
that use torque ?
thank you for your time !
Catalin Constantin
Bounce Software
http://www.bounce-software.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org