Hi,
I had a problem to get this jsp page to work (basically, it can not establish the
connection to the Informix database). However, if I write a stand alone java
module with the same driver and URL as described below, then it worked just fine.
There seemed to be a problem if I tried to do this within JSP. My webserver is
Tomcat (stand alone) and it worked fine except when it tried to connect to the
database. I can assure with you that the driverName and dbUrl are correct, I
checked them so many times. The code can only execute up to the line of
"Testing2... ha ha ha". The error I got is simply said that it could not
connect to the database. Do you see what I have done wrong? please suggest a way
for me to debug. Below is my JSP page. Thanks much in advance.
<%@ page import="java.sql.*" %>
<html>
<body>
<%
String driverName = "com.informix.jdbc.IfxDriver";
String dbUrl =
"jdbc:informix-sqli://143.183.67.14:1529/test31:INFORMIXSERVER=tng93;user=infotest;password=i5u";
out.println("<br>" + "Testing1...h ha ha ha");
try {
// Step 1. Load the driver
Class.forName(driverName);
out.println("<br>" + "Testing2...h ha ha ha");
// Step 2: Get a connection
out.println(dbUrl);
Connection myConn = DriverManager.getConnection (dbUrl);
out.println("<br>" + "Testing3...h ha ha ha");
// Step 3: Create and execute the SQL statement
Statement myStmt = myConn.createStatement ();
ResultSet myRs = myStmt.executeQuery ("SELECT * from pdscddata");
out.println("<br>" + "Testing4...h ha ha ha");
// Step 4: Process the Result Set
while (myRs.next()) {
out.println("<br>" + myRs.getString ("pdsname"));
}
}
catch (SQLException exc) {
out.println("<br> ERROR: failed to connect !");
exc.printStackTrace();
}
catch (ClassNotFoundException exc) {
out.println("<br> ERROR: failed to find a class !");
exc.printStackTrace();
}
%>
</body>
</html>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets