需要db2java.jar文件修改db2java.zip文件名称即可。
- <%@page import="java.sql.*" %>
- <%@page import="javax.sql.*"%>
- <%
- Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
- String dbUrl ="jdbc:db2:127.0.0.1:ACDB2";
- Connection con = DriverManager.getConnection(dbUrl,"administrator","111111");
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery("select * from administrator.platform_admin");
- out.println("<table border=1 width=400>");
- while (rs.next())
- {
- String col1 = rs.getString(1);
- String col2 = rs.getString(2);
- String col3 = rs.getString(3);
- String col4 = rs.getString(4);
- out.println("<tr><td>"+col1+"</td><td>"+col2+"</td><td>"+col3+"</td><td>"+col4+"</td></tr>");
- }
- out.println("</table>");
- rs.close();
- stmt.close();
- con.close();
- %>
显示如下:
1 | admin | 1 | admin |
http://www.ibm.com/developerworks/cn/db2/library/techarticles/0402chenjunwei/0402chenjunwei.html