• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help!! Error in Connecting Informix using JDBC!

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Son Bean
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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'm full of tinier men! And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic