db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashley Hayes <ashley.ha...@macalla.com>
Subject RE: torque webapp dbcp pool
Date Fri, 29 Aug 2003 09:31:47 GMT
have you got this line:
torque.dsfactory.ksi.factory=org.apache.torque.dsfactory.JndiDataSourceFacto
ry
?


-----Original Message-----
From: Catalin Constantin [mailto:catalin@bounce-software.com]
Sent: 29 August 2003 10:20
To: torque-user@db.apache.org
Subject: 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

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