servlet - NES 3.6 - informix - problem
Posted in 2000
Topics: Installation, Setup & Upgrades, SQL Development & Query Writing, Stored Procedures & SPL, Connectivity: ODBC / JDBC / .NET, Security, Permissions & Auditing, Java & JDBC Development
Hi all, I am writting a servlet that can't connect to an informix database. It's not a problem to start servlets without any database connection. The Netscape Enterprise Server 3.6 is installed and also the JDBC driver for the informix database. When I contact the servlet I get this error message in the browser: Couldn't load database driver: com.informix.jdbc.IfxDriver //Servlet: import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; public class InformixServlet extends HttpServlet { String host = "MMWWWENTWentw"; int port = 1525; String server = "wwwdb"; String database = "usr1/kunden/elva/elva.dbs"; String user = "nsuser"; String password = "mds456"; // name of the informix-Driver String driver = "com.informix.jdbc.IfxDriver"; // String of the databaseconnect String connect = "jdbc:informix-sqli:" + "//" + host + ":" + port + "/" + database + ":informixserver=" + server; public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Connection con = null; Statement stmt = null; ResultSet rs = null; resp.setContentType("text/html"); ServletOutputStream out = resp.getOutputStream(); try { //Load (and therefore register) the Informix Driver Class.forName("com.informix.jdbc.IfxDriver"); // Get a connection to the database con = DriverManager.getConnection(connect, user, password); // Create a Statement object stmt = con.createStatement(); //Execute an SQL query, get a ResultSet rs = stmt.executeQuery("SELECT fax, tel_nr FROM elva_kopf"); // Display the result set as a list out.println("<HTML><HEAD><TITLE>DATEN</TITLE></HEAD>"); out.println("<BODY>"); out.println("<UL>"); while(rs.next()) { out.println("<LI>"+rs.getString("fax") + " " + rs.getString("tel_nr")); } out.println("</UL>"); out.println("</BODY></HTML>"); } catch(ClassNotFoundException e) { out.println("Couldn't load database driver: " +e.getMessage()); } catch(SQLException e) { out.println("SQLException caught: " + e.getMessage()); } finally { // Always close the database connection. try { if (con != null) con.close(); } catch (SQLException ignored) {} } } } Configuration in CLASSPATH: CLASSPATH=/usr1/intern/seesped/java/servlets:/usr/netscape/suitespot/plugins/jav a/classes/servlet3_5.zip:/usr/netscape/suitespot/plugins/java/classes/serv3_0.zi p:/usr/netscape/suitespot/plugins/java/local-classes Configuration in obj.conf Init classpath="/usr/netscape/suitespot/wai/java/nisb.zip:/usr/netscape/suitespo t/js/samples:/usr/netscape/suitespot/plugins/java/classes/serv3_0.zip:/usr/netsc ape/suitespot/plugins/java/local-classes:/usr/netscape/suitespot/plugins/java/cl asses/servlet3_5.zip:usr1/intern/seesped/java/servlets/ifxjdbc.jar" The servlets are in the /usr1/intern/seesped/java/servlets - directory The ifxjdbc.jar - file for the informix driver are in the directory servlets and local-classes. On the web-server admin page I enabled the java interpreter and I registered the servlet directory. Your answers will be appreciated Thanks Lars