js| Data | database
Database version: DB2 UDB v7.2
Server operating system: aix4.3.3
1, shut down the Web service on the server;
2. Stop the JDBC Listener process DB2JD,DB2JD typically starts with a 6789 port service,
First Use Ps-ef | grep DB2JD to see its process number.
Then stop with kill-9 < process number > command;
3, in the database server, into the/usr/lpp/db2_07_01/java12 directory, execution./USEJDBC2 to enable JDBC2;
4, the/usr/lpp/db2_07_01/java12 under the Db2java.zip copy to their own Web project under the Web-inf\lib, if the use of Tomcat, the copy of the file renamed to Db2java.jar;
5, on the server, Su-< database instance User name >
Execute DB2JSTRT 6789 (this sentence starts the DB2JD process, 6789 is the default server listens for JDBC2 connection ports, or it can be set to any other conflict-free port. )
6, in the establishment of their own projects, the establishment of a test JSP file, the contents are as follows:
<%@ page contenttype= "text/html; charset=gb2312 "language=" java import= "java.sql.*"%>
<body>
The following is the data read from the DB2 database:<table border=1>
<%
Class.forName ("COM.ibm.db2.jdbc.net.DB2Driver"). newinstance ();
Connection con=java.sql.drivermanager.getconnection ("Jdbc:db2://192.168.168.2:6789/chaodb", "Db2inst1", "Mima");
Statement stmt=con.createstatement ();
ResultSet rst=stmt.executequery ("Select username from Tname");
while (Rst.next ())
{
Out.println ("<tr>");
Out.println ("<td>" +rst.getstring ("username") + "</td>");
Out.println ("</tr>");
}
Closing connections, releasing resources
Rst.close ();
Stmt.close ();
Con.close ();
%>
</table>
</body>
Description
192.168.168.2 is the IP address of the server;
6789 is JDBC2 to listen to the port number, and server-side settings consistent, if the server itself is 6789, then the program of this local reference, you can omit this number.
Chaodb is a database built on the server;
Db2inst1 is an instance user with a CHAODB database;
Mima is the password of the instance user db2inst1;
First in the database to create a table, the name is Tname, which has a column is username, input some data into.