Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JSP connect to AS400 DB by JDBC

272 views
Skip to first unread message

Will

unread,
Mar 4, 2002, 11:07:38 AM3/4/02
to
Hello, I'm trying to connect to get data off an AS400 and I've cobbled
together this test page to try to get something off. I'm using tomcat
3.2.3 on a windows NT box, with Jt400.jar in my classpath. I have no
problem with this page compiling in tomcat (no errors) however It
never fully loads, just sits there waiting, white screen (like if
there was a really slow connection and no timeout). If anyone has any
clues what's going on I would be very appreciative.

Here's my code:

<%@ page import="java.sql.*" %>
<%
String connectionURL =
"jdbc:as400://MYAS400;user=will;password=bananas";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>
<html><body>
<%
Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance();
connection = DriverManager.getConnection(connectionURL);
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM myfile");

while (rs.next()) {
out.println(rs.getString("column1")+"<br>");
}

rs.close();
%>

</body></html>

Also how do I go about specifying the default library list?

Thanks in advance, Will

Steve Johnson-Evers

unread,
Mar 5, 2002, 9:04:46 AM3/5/02
to
I think your question is more of a Toolbox question. There is a forum
for these questions at

http://www-912.ibm.com/j_dir/JTOpen.nsf/By+Date?OpenView

and a home page at

http://www-124.ibm.com/developerworks/oss/jt400/

that contains a FAQ, documentation, ...

I may be able to help you with some of your questions

1. Don't forget to close your statement.

2. I believe libraries can be specified using
"libraries=LIB1,LIB2,*LIBL,LIB3" with commas or spaces separating the
libraries. This is a common question and can probably be found in the
documentation, FAQ or discussion group.

3. As far as no data, here are some things I can think of to check:
- You should have a "try {} catch {}" block to catch SQL exceptions
that may be thrown by the java.sql package. Maybe there's an error being
thrown and generically caught by Tomcat (maybe Tomcat logs have
something?) but your JSP should catch and handle it as it should close
resources it has already obtained.
- Can your PC ping MYAS400?
- Are TCP and Host services running on MYAS400?
- I don't use "newInstance()" after "Class.forName()" but I don't think
that makes a difference
- If it still doesn't work you may have to turn on Toolbox tracing and
weed through the messages

-Stevers

Mutley

unread,
Mar 5, 2002, 9:21:53 AM3/5/02
to
Will,

You are not supplying the user and password on the connection e.g.
connection = DriverManager.getConnection(connectionURL,user,password);
I guess thats why it's hanging.
I don't know about the library list, I always use the schema name as the
sign on name.
Mutley

"Will" <will_w...@hotmail.com> wrote in message
news:8425110c.02030...@posting.google.com...

Kent Milligan

unread,
Mar 6, 2002, 10:54:18 AM3/6/02
to
You have to change the naming mode on the JDBC connection to *SYS to get the
library list used.

--
Kent Milligan, DB2 & BI team
PartnerWorld for Developers, iSeries
km...@us.removethis.ibm.com GO HAWKEYES!!
>>> www.iseries.ibm.com/db2
(opinions stated are not necessarily those of my employer)

0 new messages