-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: DBCP for multiple databases
PostPosted: Thu Jun 16, 2005 9:26 pm 
Newbie

Joined: Sun Dec 19, 2004 8:10 pm
Posts: 10
Location: Australia
Hello all,

I am trying to implement DBCP connection pooling on Tomcat 5 for my application.

My problem is that the application has already been written using direct connections. ie the three mapping files for the three databases each contain entries for

<property name="connection.username">
<property name="connection.password">
<property name="show_sql">
<property name="connection.url">
<property name="dialect">net.sf.hibernate.dialect.InformixDialect
<property name="connection.driver_class">
<property name="hibernate.transaction.factory_class">

I am trying to now implement these a dbcp pooled connections. I have added context entries to the server.xml.

----- snip-----
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="/frontgate" docBase="/frontgate"> <Resource name="jdbc/frontgate" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/frontgate">
<parameter> <name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- DBCP database connection settings -->
<parameter>
<name>url</name>
<value>jdbc:informix-sqli://miprd.test.nsw.gov.au:1540/frontgate:informixserver=miprdtcp</value> </parameter>
<parameter>
<name>driverClassName</name>
<value>com.informix.jdbc.IfxDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>fgate</value>
</parameter>
<parameter>
<name>password</name>
<value>mypass</value> </parameter>
<!-- DBCP connection pooling options -->
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>100</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
</ResourceParams>

<Resource name="jdbc/lac" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/lac">
<parameter> <name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<!-- DBCP database connection settings -->
<parameter>
<name>url</name>
<value>jdbc:informix-sqli://miprd.test.nsw.gov.au:1540/lac:informixserver=miprdtcp</value> </parameter>
<parameter>
<name>driverClassName</name>
<value>com.informix.jdbc.IfxDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>fgate</value>
</parameter>
<parameter>
<name>password</name>
<value>mypass</value> </parameter>
<!-- DBCP connection pooling options -->
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>100</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
</ResourceParams>

--snip---

and I have added mapping to each hbm.xml as follows

--snip-- frontgate.hibernate.hbm.xml---

<property name="connection.datasource">java:comp/env/jdbc/frontgate</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.InformixDialect</property>

--snip-- lac.hibernate.hbm.xml---

<property name="connection.datasource">java:comp/env/jdbc/lac</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.InformixDialect</property>

--snip--

I can use a test jsp page and get a connection. but when I try to run the application it falls over on the first call to a DAO.

I basically need to know if I am doing this the right way, I can't find any doco that tells me how to use DBCP for multiple databases in hibernate.

All help gratefully accepted.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.