Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Application Server
打印话题 寄给朋友 订阅主题 |
作者 | 如何在Oracle9iAS Containers for J2EE 1.0.2.2中使用oci8 driver |
nibaba
发贴: 0 积分: 0 |
于 2003-07-18 17:31
在Oracle9iAS Containers for J2EE 1.0.2.2中使用oci8 driver查询oracle数据库时jsp页面无显示。我先修改config下的data-sources.xml如下所示: <?xml version="1.0"?> <!DOCTYPE data-sources PUBLIC "Orion data-sources" "http://xmlns.oracle.com/ias/dtds/data-sources.dtd"> <data-sources> <!-- An example/default DataSource that uses Oracle JDBC-driver to create the connections. This tag creates all the needed kinds of data-sources, transactional, pooled and EJB-aware sources. The source generally used in application code is the "EJB" one - it provides transactional safety and connection pooling. Oracle thin driver could be used as well, like below. url="jdbc:oracle:thinhost:port:sid" --> <data-source class="com.evermind.sql.DriverManagerDataSource" name="OracleDS" location="jdbc/OracleCoreDS" xa-location="jdbc/xa/OracleXADS" ejb-location="jdbc/OracleDS" connection-driver="oracle.jdbc.driver.OracleDriver" username="workbrain" password="workbrain" url="jdbc:oracle:oci8puppy.www.chinatps.com" language="java" inactivity-timeout="30" /> </data-sources> jsp文件如下所示: <%@ page contentType="text/html; charset=shift_jis" %> <%@ page import="java.util.*" %> <%@ page import="java.text.*" %> <%@ page import="java.sql.*" %> <%@ page import="javax.sql.*" %> <%@ page import="javax.naming.*" %> <%@ page import="java.io.*" %> <html> <head></head> <body> <h1>hello!</h1> <% Connection conn = null; Context ic = new InitialContext(); Statement sttSql = null; ResultSet rs = null; out.println("<font size=8 color=red>start!</font>"); try{ DataSource ds = (DataSource) ic.lookup("jdbc/OracleDS"); conn = ds.getConnection(); sttSql = conn.createStatement(); rs = sttSql.executeQuery("select emp_name from employee"); while(rs.next()){ out.println(rs.getString("emp_name") + "<br>"); } out.println("<font size=8 color=red> end! </font>"); } catch(Exception e){ out.println("<font size=8 color=red>error!</font>"); } rs.close(); sttSql.close(); conn.close(); ic.close(); %> </body> </html> 学java的朋友,请一起来投票让sun推出中文jdk文档!!! |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |