wood burning stoves 2.0*
The moose likes Websphere and the fly likes Help!! Error in Connecting Informix using JDBC! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Help!! Error in Connecting Informix using JDBC!" Watch "Help!! Error in Connecting Informix using JDBC!" New topic
Author

Help!! Error in Connecting Informix using JDBC!

Son Bean
Greenhorn

Joined: Sep 14, 2001
Posts: 12
i have written the following code with JBuilder, and it works well with Tomcat, but it cannot be run if i place it into some
existing application of WAS, can any1 help me?
package untitled25;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
public class Servlet1 extends HttpServlet {
private static final String CONTENT_TYPE = "text/html";
/**Initialize global variables*/
public void init() throws ServletException {
}
/**Process the HTTP Get request*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Servlet1</title></head>");
out.println("<body>");
out.println("
The servlet has received a GET. This is the reply.
");
jdbcConn(out);
out.println("</body></html>");
}
public void jdbcConn(PrintWriter out)
{
String cmd = null;
int rc;
Connection conn = null;
String newURL = "jdbc:informix-sqli:";
newURL = newURL + "//157.168.136.20:15260/stores:informixserver=hkgrs010_ol1;";
newURL = newURL + "user=informix;password=informix";
out.println("Connection starting....");
try
{
Class.forName("com.informix.jdbc.IfxDriver");
}
catch(Exception e)
{
System.out.println("ERROR: failed to load informix JDBC driver.");
e.printStackTrace();
}
try
{
conn = DriverManager.getConnection(newURL,"informix","informix");
}
catch (SQLException e)
{
System.out.println("ERROR: failed to connect!");
e.printStackTrace();
}
try
{
Statement stmt = conn.createStatement();
cmd = "select * from location";
ResultSet rs = stmt.executeQuery(cmd);
int i = 0;
out.println("location_id,loc_type");
while(rs.next())
{
String value1 = rs.getString("location_id");
String value2 = rs.getString("loc_type");
out.println("
row " + i + " : " + value1 + value2 + "
");
i++;
}
rs.close();
stmt.close();
}
catch(SQLException e)
{
System.out.println("ERROR: execution failed - statment: " + cmd);
System.out.println("ERROR: " + e.getMessage());
e.printStackTrace();

}
}
public void destroy() {
}
}
Son Bean
Greenhorn

Joined: Sep 14, 2001
Posts: 12
and the following is the error i got:
An Error Occurred While Processing Your Request...
The following error has been detected:

com.ibm.servlet.engine.webapp.WebAppErrorReport:
Full Stack Trace:

com.ibm.servlet.engine.webapp.WebAppErrorReport:
at com.ibm.servlet.engine.webapp.WebApp.sendError(WebApp.java:542)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:92)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:123)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:106)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:125)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:315)
at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:313)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:242)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:122)
Son Bean
Greenhorn

Joined: Sep 14, 2001
Posts: 12
could anyone kind enough to help me?
i am a beginner in websphere, i have follow the WAS online document guide but still no help.hope you guys can give me some idea in what i have to do!
Jun Hong
Ranch Hand

Joined: Sep 05, 2001
Posts: 181
Go to logs of in WebSphere/AppSever directory. Open default_server_stdout.log. You may get the System.out printed out. Then, you may get a more specific error.
Jun Hong


Jun Hong<br />SCJP, SCJD, SCWCD, SCEA<br />IBM Certified Systems Expert(V4.0)
Son Bean
Greenhorn

Joined: Sep 14, 2001
Posts: 12
thanks hong!
i find out that the problem is fail to load the JDBC driver for websphere, where should i place the ifxjdbc.jar file(the JDBC driver for informix)? i already add the ifxjdbc.jar file to the classpath of my machine.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help!! Error in Connecting Informix using JDBC!
 
Similar Threads
Sending password/login info using sockets
NullPointerException At Statement stmt = conn.createStatement();
Connection reset by peer:JVM_recv in socket input stream read
problem with response commitment
Please Help! I Have Worked On IT For Days.