<%
out.print("我的测试开始"+"<br/>");
DataSource ds = null;
try{
InitialContext ctx=new InitialContext();
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/sql/Index.html'>mysql");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
String strSql = " select * from test_user";
ResultSet rs = stmt.executeQuery(strSql);
while(rs.next()){
out.print(rs.getString(1)+"<br/>");
} rs.close(); stmt.close(); conn.close(); out.print("我的测试结束");
}
catch(Exception ex){
out.print("出现例外,信息是:"+ex.getMessage());
ex.printStackTrace();
}
%>
</head>
<body>
</body>
</html> 上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17]
|