<%@ page contenttype="text/html;charset=gbk" %>
<%@ page import= "java.sql.* " %>
<%@ page import= "javax.sql.* " %>
<%@ page import= "javax.naming.* "%>
<html>
<head>
<title> </title>
<meta name="generator" content="editplus2.11">
</head>
<body>
<%
// 从weblogic 8 文档抄来
context ctx = null;
hashtable ht = new hashtable();
ht.put(context.initial_context_factory,"weblogic.jndi.wlinitialcontextfactory");
ht.put(context.provider_url,"t3://127.0.0.1:7001");
// ht.put(context.security_principal, "admin");
// ht.put(context.security_credentials, "11111111");
connection conn = null;
statement stmt = null;
resultset rs = null;
try {
ctx = new initialcontext(ht);
datasource ds = (datasource)ctx.lookup ("ejbpool");
conn = ds.getconnection();
stmt = conn.createstatement();
stmt.execute("select * from accounts");
rs = stmt.getresultset();
while ( rs.next()){
out.println( rs.getstring(1)+"___");
out.println( rs.getstring(2)+"___");
out.println( rs.getstring(3)+"<br>");
}
stmt.close();
stmt=null;
conn.close();
conn=null;
}catch (exception e) {
out.println("错误 !! err !" );
}
finally {
try {
ctx.close();
} catch (exception e) {
out.println("ctx err !" ); }
try {
if (rs != null) rs.close();
} catch (exception e) {
out.println("rs err !" ); }
try {
if (stmt != null) stmt.close();
} catch (exception e) {
out.println("stmt err !" ); }
try {
if (conn != null) conn.close();
} catch (exception e) {
out.println("conn err !" ); }
}
%>
</body>
</html>
