« | September 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | | | | |
|
统计 |
blog名称:小雨 日志总数:262 评论数量:1273 留言数量:15 访问次数:4677853 建立时间:2005年1月8日 |
| 
|
W3CHINA Blog首页 管理页面 写新日志 退出
[知识积累]使用weblogic 8.1 的jdbc |
小雨 发表于 2007/3/17 19:47:59 | 500)this.width=500'>
<%@ page session="true" %><%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="javax.sql.*"%><%@ page import="java.sql.*"%> <%@ page import="javax.naming.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE>BEA WebLogic Server Out-of-the-Box Examples Index Page</TITLE><META http-equiv=Content-Type content=text/html;CHARSET=iso-8859-1><META content="BEA WebLogic Server" name=description><META content="BEA WebLogic Server" name=keywords><META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD><BODY vLink=#9999cc aLink=#0000cc link=#3366cc bgColor=#ffffff><!-- CONTENT --><%!java.sql.Connection conn = null;String str=null;Statement myStatement = null;String sql =null;ResultSet myResultSet=null;
public Connection getCon() { try { Context ctx = new InitialContext(); javax.sql.DataSource ds = (javax.sql.DataSource)ctx.lookup("MyJndi"); conn = ds.getConnection(); sql = "select * from dbo.authors where au_lname='White'"; myStatement=conn.createStatement(); myResultSet=myStatement.executeQuery(sql); while(myResultSet.next()) { str=myResultSet.getString("au_fname"); System.out.println("the author first name is "+str); } myResultSet.close();
// conn.close();
} catch (Exception e) { str=e.toString();; return conn; } return conn;}%><%
String url = "http://" + request.getServerName() + ":" + request.getServerPort(); session.setAttribute("url",url); getCon();%><%=session.getAttribute("url")+str%></BODY></HTML>
|
阅读全文(4550) | 回复(0) | 编辑 | 精华 |
|