67,513
社区成员
发帖
与我相关
我的任务
分享
<%@ page language="java" import="java.util.*,java.sql.*,javax.sql.*" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'connectDB2.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<center>
hello!
<p>aaaaa</p>
<%
//String url="jdbc:db2:sample";
String url="jdbc:db2://localhost:5000/sample";
String user="db2admin";
String password="123";
try{
//DriverManager.registerDriver(new COM.ibm.db2.jdbc.app.DB2Driver());
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
Connection conn= DriverManager.getConnection(url,user,password);
//Statement stmt=conn.createStatement();
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from RFID";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {
%>
<%=rs.getInt(1) %>
<%
}
}
catch(Exception e)
{
e.printStackTrace();
}
%>
</center>
</body>
</html>