racleDS"); //注意这里哦和前面对应
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM TAB");
while ( rs.next() ) {
out.println( rs.getString("TNAME") + "<br>");
}
conn.close();
%>
四、请访问http://localhost:8080/oracle-test
一切都测试OK的,如果有什么不对的地方请指哦,我也是学习的。这是一个快速的配置方法,在过一些时间我会把每个属性表示什么给大家说说.
第一次接触ejb(4)
时间:2011-01-19
经我根据摸索Sybase ASA更改后如下:
1 在Sql Anywhere 9目录的java目录下找到jdbcdrv.zip,拷贝到jboss-3.2.5的server\default\lib目录下
2 在jboss-3.2.5\docs\examples\jca目录下找到sybase-ds.xml拷贝到jboss-3.2.5\server\default\deploy目录下
3 修改sybase-ds.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!-- ===================================================================== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- New ConnectionManager setup for Sybase ASE/ASA jConnect driver -->
<!-- Thanks to Marc Zampetti <zampetti@aol.net> -->
<!-- This is a minimal example. See the generic example for other stuff -->
<!-- ===================================================================== -->
<!-- $Id: sybase-ds.xml,v 1.1.2.2 2003/09/05 16:38:24 patriot1burke Exp $ -->
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/SybaseDB</jndi-name>
<!-- Sybase jConnect URL for the database.
NOTE: The hostname and port are made up values. The optional
database name is provided, as well as some additinal Driver
parameters.
-->
<connection-url>jdbc:sybase:Tds:Gibeon:2638/QZCFTraining?JCONNECT_VERSION=4</connection-url>
<driver-class>com.sybase.jdbc.SybDriver</driver-class>
<user-name>DBA</user-name>
<password>SQL</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.SybaseExceptionSorter</exception-sorter-class-name>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->
</local-tx-datasource>
</datasources>
4 修改index.jsp文件,如下:
<%@page contentType="text/html"%>
<%@ page import="java.sql.*, javax.sql.DataSource, javax.naming.InitialContext" %>
<h3>Test Sybase DB</h3>
<%
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:/jdbc/SybaseDB"); //注意这里哦和前面对应
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM Trainee");
while ( rs.next() ) {
out.println( rs.getString("name") + "<br>
|