使用weblogic管理数据源

2019-04-15 13:58发布

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=GBK" language="java"
errorPage=""%>
<%@ page import="javax.naming.*,java.sql.*,javax.sql.*"%>




<%
//初始化Context,使用InitialContext初始化Context
Context ctx = new InitialContext();
//通过JNDI查找数据源,该JNDI就是部署数据源所指定的JNDI
DataSource ds = (DataSource) ctx.lookup("mmysql");
//获取数据库连接
Connection conn = ds.getConnection();
//获取Statement
Statement stmt = conn.createStatement();
//执行查询,返回ResulteSet对象
ResultSet rs = stmt.executeQuery("select * from t_book");
while (rs.next()) {
out.println(rs.getString(1) + "  " + rs.getString(2)
+ "
");
}
rs.close();
stmt.close();
conn.close();
%>



[img]http://dl.iteye.com/upload/picture/pic/132017/87b234bf-6060-366e-8071-07d9e1696f98.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132019/ddce9cdf-d5f0-389a-81df-73e460a74203.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132021/62344aab-f8ee-3bda-abc6-de7bfe4d8c5b.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132023/05ab98b1-562f-3b34-881e-0adcbbb05029.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132025/5ae4eff2-32a5-3889-b408-272186887ea4.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132027/e2a346e2-0d4e-3d58-b560-9b035492817c.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132029/1b54a65b-edfd-394d-a775-1fba87cdc6ef.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132031/2afd2c28-401e-3fcc-b293-99c23f3145b6.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132033/5bf135ec-8555-3f04-82ac-483f0a7f8397.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132035/4a72c31d-fb5d-31e9-86ef-db0862341d77.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132037/cbd014e0-2b52-3974-ac94-9f8b98761765.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132039/674c7f29-65a4-36b2-804e-85be22ea50b7.png[/img]

[img]http://dl.iteye.com/upload/picture/pic/132041/b686d9df-9391-3da2-ba7a-3d5ae4bd85b3.png[/img]