connecting to as400 via java servlet..not quite right

D

Drew

Hi All:

I have taken a standalone Java program that I can run from a command
prompt and succesfully execute a query and retrieve data from the 400.

I'm using the AS400JDBCDriver kit that can be downloaded and all I had
to do was to add a reference to the zip file to my Classpath.

I'm now trying to get the same program to work as a web application
under Tomcat 4. I already have other web apps working succesfully
under Tomcat 4. I've converted the Java program over to a Java
servlet.

I think my problem is getting the Java servlet to see the AS400 data
source whereas the standalone Java program was able to see it as soon
as I set the classpath environment variable correctly.

I have dropped 'jt400.jar' into the C:\Program Files\Apache
Group\Tomcat 4.1\common\lib folder

Then, in C:\Program Files\Apache Group\Tomcat 4.1\conf\server.xml, I
have added the following after the last </context> and before </host>.

<Resource name="jdbc/as400" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/as400">
<parameter>
<name>username</name>
<value>USERNAME</value>
</parameter>
<parameter>
<name>password</name>
<value>PASSWORD</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.ibm.as400.access.AS400JDBCDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:as400://172.16.1.2/javatest</value>
</parameter>
</ResourceParams>

When I try to execute this particular servlet, the Apache Tomcat
service gets stopped by whatever is wrong, and hence the page times
out after a bit and I get the Page Not Found Error.

All my existing servlets still work though. This is the first servlet
I've written to try and pull data from the AS400. All previous ones
pull data from Access databases which are set up as Data Sources under
control panel.

I've used my correct USERNAME and PASSWORD in server.xml above where
indicated.

The third line from the bottom has the IP address for the AS400 host
which is correct.

I am unclear on the word immediately following the host IP or name
though. I found the below guide:

<value>jdbc:as400://<$YOUR_HOST>/<$YOUR_COLLECTION></value>

It calls javatest a 'collection'. I'm not sure what is needed here.
I tried 'javatest' which obviously doesn't work.

I think my problem is just getting Tomcat to be able to see and access
the 400 datasource during the run of the servlet.

From what I've read, I'm thinking that all I needed to do was drop
the jt400.jar file into the common\lib folder and then go and put the
above stuff about the 400 in the server.xml file.

Can anyone provide any insight into where I'm goofing up?

Thanks very much!!!
Drew
 
R

Rhino

Drew said:
Hi All:

I have taken a standalone Java program that I can run from a command
prompt and succesfully execute a query and retrieve data from the 400.

I'm using the AS400JDBCDriver kit that can be downloaded and all I had
to do was to add a reference to the zip file to my Classpath.

I'm now trying to get the same program to work as a web application
under Tomcat 4. I already have other web apps working succesfully
under Tomcat 4. I've converted the Java program over to a Java
servlet.

I think my problem is getting the Java servlet to see the AS400 data
source whereas the standalone Java program was able to see it as soon
as I set the classpath environment variable correctly.

I have dropped 'jt400.jar' into the C:\Program Files\Apache
Group\Tomcat 4.1\common\lib folder

Then, in C:\Program Files\Apache Group\Tomcat 4.1\conf\server.xml, I
have added the following after the last </context> and before </host>.

<Resource name="jdbc/as400" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/as400">
<parameter>
<name>username</name>
<value>USERNAME</value>
</parameter>
<parameter>
<name>password</name>
<value>PASSWORD</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.ibm.as400.access.AS400JDBCDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:as400://172.16.1.2/javatest</value>
</parameter>
</ResourceParams>

When I try to execute this particular servlet, the Apache Tomcat
service gets stopped by whatever is wrong, and hence the page times
out after a bit and I get the Page Not Found Error.

All my existing servlets still work though. This is the first servlet
I've written to try and pull data from the AS400. All previous ones
pull data from Access databases which are set up as Data Sources under
control panel.

I've used my correct USERNAME and PASSWORD in server.xml above where
indicated.

The third line from the bottom has the IP address for the AS400 host
which is correct.

I am unclear on the word immediately following the host IP or name
though. I found the below guide:

<value>jdbc:as400://<$YOUR_HOST>/<$YOUR_COLLECTION></value>

It calls javatest a 'collection'. I'm not sure what is needed here.
I tried 'javatest' which obviously doesn't work.

I think my problem is just getting Tomcat to be able to see and access
the 400 datasource during the run of the servlet.

From what I've read, I'm thinking that all I needed to do was drop
the jt400.jar file into the common\lib folder and then go and put the
above stuff about the 400 in the server.xml file.

Can anyone provide any insight into where I'm goofing up?

Thanks very much!!!
Drew
I don't know the answers to your questions but you *might* find something
useful among the Tomcat HOW-TOs at
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/index.html or in the DB2
manuals for AS/400, although I'd be a little surprised if the DB2 manuals
talked about Tomcat specifically.

If that doesn't work, any of the following places is more likely to give you
the answer you want than comp.lang.java.programmer:
comp.lang.java.databases, comp.databases.ibm-db2, or the Tomcat mailing
list, to which you can subscribe at
http://jakarta.apache.org/site/mail2.html#Tomcat.

Rhino
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top