Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Application Server  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 如何在Oracle9iAS Containers for J2EE 1.0.2.2中使用oci8 driver
nibaba



发贴: 0
积分: 0
于 2003-07-18 17:31 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
在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:thinAngryhost: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:oci8Angrypuppy.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>




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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