The installed DB2 V8.1 self-contained DB2 driver cannot afford, write a JSP page, when using the forname () load test connection

xiaoxiao2021-03-06  52

DB2JAVA.ZIP driver provided by DB2 V8.1 is available, it is a bit strange that it must not be reported when it is in combination with WSAD or WebSphere, and it will appear when using RESIN, Tomcat, etc. The question you mentioned! It's a little ft!

I use it straight, the server is Tomcat, the drive path is set in the classpath, and one test code is also put below Common / Lib as follows: <% // Program 2-16: Using JSP Connection DB2 Database // Program Name : Testdb2.jsp%> <% @ page contenttype = "text / html; charSet = GB2312"%> <% @ page import = "java.sql. *"%> <% class.forname "Com.ibm.db2.jdbc.app.db2driver"). NewInstance (); // Indicates the driver used to connect

String URL = "JDBC: DB2: // localhost: 5000 / sample"; // Sample "; SAMPLE is the connected database name string user =" db2admin "; string password =" admin "; connection conn = drivermanager.getConnection (URL, User , password); // Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); Statement stmt = conn.createStatement (); String sql = "select * from STUDENT"; ResultSet rs = stmt.executeQuery (sql) WHILE (rs.next ()) {%> Your first field content is: <% = rs.getstring (1)%> Your second field content is: <% = rs.getstring (2) %> <%}%> <% rs.close (); stmt.close (); conn.close ();%>

Error message: No Suitable Driver

The strange thing is as "Xiaobang", it is set up in WSAD, and the same driver with JNDI can be accessed normally.

转载请注明原文地址:https://www.9cbs.com/read-115229.html

New Post(0)