The Artima Developer Community
Sponsored Link

Java Buzz Forum
DB2 DataSources and Tomcat5

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Marc Logemann

Posts: 594
Nickname: loge
Registered: Sep, 2002

Marc Logemann is founder of www.logentis.de a Java consultancy
DB2 DataSources and Tomcat5 Posted: Feb 29, 2004 3:54 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Marc Logemann.
Original Post: DB2 DataSources and Tomcat5
Feed Title: Marc's Java Blog
Feed URL: http://www.logemann.org/day/index_java.xml
Feed Description: Java related topics for all major areas. So you will see J2ME, J2SE and J2EE issues here.
Latest Java Buzz Posts
Latest Java Buzz Posts by Marc Logemann
Latest Posts From Marc's Java Blog

Advertisement

Setting up DataSources with Tomcat is not too hard, but doing it without using the default org.apache.naming.factory.DbcpDataSourceFactory or org.apache.commons.dbcp.BasicDataSourceFactory (where is the difference by the way?) needs some kind of research.

Because my target database is a DB2 which runs on Windows at the moment and will reside on an IBM iSeries during production, there are some options. For development i am using the db2 on windows, so i searched what IBM offers with their universal driver for db2 (db2jcc.jar). To my surprise i found an ObjectFactory implementation of their datasources called DB2DataSourceFactory, and inside tomcat you can just define it this way:

<ResourceParams name="jdbc/db2">
<parameter>
<name>factory</name>
<value>com.ibm.db2.jcc.DB2DataSourceFactory</value>
</parameter>
[..]

This was easy. Because IBM offers more than one DataSource implementation, you can just submit the desired type of DataSource in Tomcat:

<Resource type="com.ibm.db2.jcc.DB2SimpleDataSource" name="jdbc/db2"/>

The DB2SimpleDataSource is not really too exciting, it doesnt provide pooling or anything else breathtaking, but for development this was perfect, i dont want to introduce problems for questions that i dont have at the moment. But if you consult the massive IBM DB2 library, you will find out that for various JDBC Types, several DataSources can be obtained. In my case i am using the Type4 Driver because i like being independent of any database client on my machine (in fact the complete DB2 is also on my devel machine, so i could also use a Type2 Driver - a pooling DataSource is only available for Type2 at the moment from IBM).

The beautiful thing about the db2jcc.jar (universal driver) is that you can connect with Type2 and Type4 with the same driver, the JDBC URL defines the Type at the end. Another cool thing is that you can connect to various DB2s with this driver, so there is no problem using it with DB2 on iSeries or DB2 on z/OS.

But we are in IBM land, you can also use the iSeries based JTopen library, that API ships another JDBC driver for connecting to the DB2 for iSeries. In fact this one also has a pooling DataSource implemenation, but when you think you can easily plug that into Tomcat, you are wrong. The JTOpen Team doesnt provide (and it was impossible to convince them otherwise some months ago) a ObjectFactory that you can define the DataSource as a JNDI resource in Tomcat. I wrote one myself (really wasnt that hard) and so it turns out that this is another neat option to connect to a DB2.

I dont know if i like having many options for one problem. At least not when it comes to JDBC drivers and DataSources from one Company. Perhaps they should streamline all their projects, but its IBM and they have a lof of platforms, perhaps it must be this way.

At the end, i really much like Tomcat5, it feels a lot better than 4. Even if its hip to bash tomcat in one or another way these days, i like that piece of software.

Read: DB2 DataSources and Tomcat5

Topic: Kaffe 1.1.4 Now Playing - What's New? Previous Topic   Next Topic Topic: Mac and Me

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use