Hi Ryan,
I did this like a month ago. I was also scratching my head in search for
good docs on this topic and I found some pointers and help on this list.
The setup that I have is tomcat + commons DBCP.
Note though that there is at least another way I haven't tried yet and that
is by setting up Castor JDO database pooling with poolman.
So here it goes:
First you need to make sure you have the DBCP needed jars:
commons-dbcp.jar; commons-pool.jar; commons-collections.jar;
<your jdbc driver jar>
you can either put them into the tomcat's commons/lib directory if the JNDI
resource is global or in your application's lib directory if the JNDI
resource is local to the application context.
Second you need to create the JNDI resource in your server.xml file. Below,
I paste as an example mine:
Note: this example uses mysql settings.
--------
<Resource auth="Container" name="jdbc/alias_database_name"
scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams
name="jdbc/alias_database_name">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://your.database.server:3306/database_name</value>
</parameter>
<parameter>
<name>password</name>
<value>this_is_the_password</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>100</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>username</name>
<value>this_is_the_username</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30000</value>
</parameter>
</ResourceParams>
----------
you can put this inside your application <context> tag.
Third, you need to add this snippet to your application's web.xml file
inside <web-app> tag:
---------
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/alias_database_name</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
---------
Fourth, your database.xml file should look like:
---------
<!DOCTYPE databases PUBLIC "-//EXOLAB/Castor JDO Configuration DTD Version
1.0//EN"
"http://castor.exolab.org/jdo-conf.dtd">
<database name="alias_database_name" engine="mysql">
<jndi name="java:comp/env/jdbc/alias_database_name" />
<mapping href="mapping.xml"/>
</database>
---------
Fifth is the test:
when you initialize your JDO instance try:
jdo.setDatabasePooling(true);
and then
logger.println("Pooling: "+jdo.getDatabasePooling());
logger.println("Autostore: "+jdo.isAutoStore());
logger.println("Lock timeout: "+jdo.getLockTimeout());
logger.println("Transaction Manager: "+jdo.getTransactionManager());
and check if Transaction manager is java/TransactionManager
-----
Sixth fire up netstat -an and watch your connections to the database :-)
hope I covered,
cristi
At 04:14 PM 9/19/2002 -0400, you wrote:
>Has anyone attempted/been successful in configuring Castor JDO via JNDI with
>Tomcat 4? If so, would you mind sharing? Thanks.
>
>Ryan-
>
>-----------------------------------------------------------
>If you wish to unsubscribe from this mailing, send mail to
>[EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev