欢迎光临
我们一直在努力

jsp实现的简单Weblogic 8.11连接池-JSP教程,Jsp/Servlet

建站超值云服务器,限时71元/月

<%@ 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>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » jsp实现的简单Weblogic 8.11连接池-JSP教程,Jsp/Servlet
分享到: 更多 (0)

相关推荐

  • 暂无文章