help creating datasource

From: David McDivitt (x12code-del_at_del-yahoo.com)
Date: 10/14/04


Date: Thu, 14 Oct 2004 11:09:56 -0500

I have made several web apps using struts in Websphere 5.0. For each one I
copied a template app having everything I need. We have some batch
processing which needs to be done, and instead of using struts I want to
make a single standalone class for one of the jobs. The database is IBM DB2.

I picked through the struts stuff and copied what seemed to make sense into
the class I'm making. I got the runtime error:

  javax.naming.NoInitialContextException: Cannot instantiate class:
  COM.ibm.db2.jdbc.app.DB2Driver. Root exception is
  java.lang.ClassCastException: COM.ibm.db2.jdbc.app.DB2Driver

After searching google I found where someone said this is a bug in the IBM
driver and it's necessary to unzip db2java.zip into the project.
Unfortunately there are four files in the zip file which have a lower case
"com" instead of an upper case "COM", and the zip file will not import
without errors due to name conflict. So I edited those classes changing each
occurrence of com/ibm to COM/ibm and created another zip file which does
import OK. If classes are imported they must be placed at Web
Content/WEB-INF/classes, but they are not found, and if the project is
rebuilt they are deleted. To be used, source must exist at the Java Source
portion of the project.

I tried placing the repaired zip file at Web Content/WEB-INF/lib. When I
attempt to run I get a Windows GPF.

I also tried bypassing the context stuff, instantiating the DB2Driver class,
and setting properties in that. Unfortunately the DB2Driver class does not
have any properties to be set directly, and can only be configured by use of
a context object, it would seem.

If anyone has an example of how to create an IBM DB2 datasource, connection,
and execute an SQL statement, in one single class, I would appreciate help.
Thanks



Relevant Pages

  • Re: help creating datasource
    ... >I have made several web apps using struts in Websphere 5.0. ... The database is IBM DB2. ... >and setting properties in that. ... >If anyone has an example of how to create an IBM DB2 datasource, connection, ...
    (comp.lang.java.databases)
  • Re: struts newbie question
    ... >Is the following doable in Struts: ... >I'm very new to using a java framework for web apps. ... Are you saying you want the app to update the field in the database ...
    (comp.lang.java.programmer)