国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Jboss3.0-tomcat4.03的配置-4(數據庫的配置)

2019-11-18 16:03:38
字體:
來源:轉載
供稿:網友

  (灰狐動力-中間件技術論壇 by huihoo.com Etre)

Jboss3.0-Tomcat4.03的數據庫的配置(以Oracle為例)
一、 請將classes12.zip加入classpath中去。
二、請參況hsqldb-service.xml文件編寫Oracledb-service.xml文件
請打開serverdefaultdeploy目錄下的hsqldb-service.xml文件,這就是一個Jboss3.0_Tomcat4.03下實現數據庫連接的例子,它是連接hsql數據庫的它的內容如下:
<?xml version="1.0" encoding="UTF-8"?>

<!-- ===================================================================== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- ===================================================================== -->

<!-- $Id: hsqldb-service.xml,v 1.2.2.5 2002/06/23 21:25:58 d_jencks EXP $ -->


<server>

<!-- ==================================================================== -->
<!-- New ConnectionManager setup for default hsql dbs -->
<!-- Build jmx-api (build/build.sh all) and view for config documentation -->
<!-- ==================================================================== -->

<mbean code="org.jboss.resource.connectionmanager.LocalTxConnectionManager" name="jboss.jca:service=LocalTxCM,name=hsqldbDS">

<!-- Include a login module configuration named HsqlDbRealm.
Update your login-conf.xml, here is an example for a
ConfiguredIdentityLoginModule:

<application-policy name = "HsqlDbRealm">
<authentication>
<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
<module-option name = "<module-option name = "userName">sa</module-option>
<module-option name = "pass
Word"></module-option>
<module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=hsqldbDS</module-option>
</login-module>
</authentication>
</application-policy>

NOTE: the application-policy name attribute must match
SecurityDomainJndiName, and the
module-option name = "managedConnectionFactoryName"
must match the object name of the ConnectionManager you are configuring here.
-->
<!--uncomment out this line if you are using the DB2DbRealm above
<attribute name="SecurityDomainJndiName">HsqlDbRealm</attribute>
-->

<depends optional-attribute-name="ManagedConnectionFactoryName">
<!--embedded mbean-->
<mbean code="org.jboss.resource.connectionmanager.RARDeployment" name="jboss.jca:service=LocalTxDS,name=hsqldbDS">

<attribute name="JndiName">DefaultDS</attribute>
<attribute name="ManagedConnectionFactoryProperties">
<properties>
<config-property name="ConnectionURL" type="java.lang.String">jdbc:hsqldb:hsql://localhost:1476</config-property>
<config-property name="DriverClass" type="java.lang.String">org.hsqldb.jdbcDriver</config-property>
<config-property name="UserName" type="java.lang.String">sa</config-property>
<config-property name="Password" type="java.lang.String"></config-property>
</properties>
</attribute>

<!--Below here are advanced properties -->
<!--hack-->
<depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper</depends>
<depends>jboss:service=Hypersonic</depends>

</mbean>
</depends>
<depends optional-attribute-name="ManagedConnectionPool">
<!--embedded mbean-->
<mbean code="org.jboss.resource.connectionmanager.JBossManagedConnectionPool" name="jboss.jca:service=LocalTxPool,name=hsqldbDS">

<attribute name="MinSize">0</attribute>
<attribute name="MaxSize">50</attribute>
<attribute name="BlockingTimeoutMillis">5000</attribute>
<attribute name="IdleTimeoutMinutes">15</attribute>
<!--criteria indicates if Subject (from security domain) or app supplied
parameters (sUCh as from getConnection(user, pw)) are used to distinguish
connections in the pool. Choices are
ByContainerAndApplication (use both),
ByContainer (use Subject),
ByApplication (use app supplied params only),
ByNothing (all connections are equivalent, usually if adapter supports
reauthentication)-->
<attribute name="Criteria">ByContainer</attribute>
</mbean>
</depends>
<depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager</depends>

<depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager</depends>

<attribute name="TransactionManager">java:/TransactionManager</attribute>

<!--make the rar deploy! hack till better deployment-->
<depends>jboss.jca:service=RARDeployer</depends>

</mbean>


<!-- Moved to end to test anonymous depends -->

<mbean code="org.jboss.jdbc.HypersonicDatabase"
name="jboss:service=Hypersonic">
<attribute name="Port">1476</attribute>
<attribute name="Silent">true</attribute>
<attribute name="Database">default</attribute>
<attribute name="Trace">false</attribute>
</mbean>

</server>
在<!-- -->之間沒有用的一些說明,所以去掉這一些說明后經過改寫一個存取oracle數據庫的服務的XML的文件是Oracledb-service.xml
<?xml version="1.0" encoding="UTF-8"?>

<server>

<mbean code="org.jboss.resource.connectionmanager.LocalTxConnectionManager" name="jboss.jca:service=LocalTxCM,name=oracleDS">


<depends optional-attribute-name="ManagedConnectionFactoryName">
<!--embedded mbean-->
<mbean code="org.jboss.resource.connectionmanager.RARDeployment" name="jboss.jca:service=LocalTxDS,name=oracleDS">

<attribute name="JndiName">OracleDS</attribute>
<attribute name="ManagedConnectionFactoryProperties">
<properties>
<config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:thin:@cuipeng:1521:Ora8</config-property>
<config-property name="DriverClass" type="java.lang.String">oracle.jdbc.driver.OracleDriver</config-property>
<config-property name="UserName" type="java.lang.String">system</config-property>
<config-property name="Password" type="java.lang.String">manager</config-property>
</properties>
</attribute>

<depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper</depends>
</mbean>
</depends>
<depends optional-attribute-name="ManagedConnectionPool">
<!--embedded mbean-->
<mbean code="org.jboss.resource.connectionmanager.JBossManagedConnectionPool" name="jboss.jca:service=LocalTxPool,name=oracleDS">

<attribute name="MinSize">0</attribute>
<attribute name="MaxSize">50</attribute>
<attribute name="BlockingTimeoutMillis">5000</attribute>
<attribute name="IdleTimeoutMinutes">15</attribute>
<attribute name="Criteria">ByContainer</attribute>
</mbean>
</depends>
<depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager</depends>

<depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager</depends>

<attribute name="TransactionManager">java:/TransactionManager</attribute>

<depends>jboss.jca:service=RARDeployer</depends>

</mbean>

</server>
請大家對比兩個文件的不同之外,很容易寫出其它數據庫的存取服務了,主要的是下面這個部分
<mbean code="org.jboss.resource.connectionmanager.RARDeployment" name="jboss.jca:service=LocalTxDS,name=oracleDS">

<attribute name="JndiName">OracleDS</attribute><!--這個地方是JNDI的名字在ejb或jsp中調用的是java:/OracleDS - ->
<attribute name="ManagedConnectionFactoryProperties">
<properties>
<config-property name="ConnectionURL" type="java.lang.String">jdbc:oracle:thin:@cuipeng:1521:ora8</config-property>
<config-property name="DriverClass" type="java.lang.String">oracle.jdbc.driver.OracleDriver</config-property>
<config-property name="UserName" type="java.lang.String">system</config-property>
<config-property name="Password" type="java.lang.String">manager</config-property>
</properties>
</attribute>
<depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper</depends>
</mbean>
還有就是各個部分的名字了name=oracleDS
三、測試數據的連接列子(我用的是jsp)
你必需要編寫.war或.ear包來測試一個簡易的做法就是:
一、 在deploy目錄下建立oracle-test.war目錄。
二、在oracle-test.war目錄下建立WEB-INF目錄,其中有兩個文件
jboss-web.xml和web.xml
內容分別是
jboss-web.xml內容是
<jboss-web>
</jboss-web>
web.xml內容是
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
</web-app>
三、在oracle-test.war目錄下建立新文件index.jsp其內容是
<%@page contentType="text/Html"%>
<%@ page import="java.sql.*, javax.sql.DataSource, javax.naming.InitialContext" %>

<h3>Test Oracle DB</h3>

<%


InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:/OracleDS"); //注意這里哦和前面對應
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的,如果有什么不對的地方請指哦,我也是學習的。這是一個快速的配置方法,在過一些時間我會把每個屬性表示什么給大家說說.

(出處:http://www.survivalescaperooms.com)



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新沂市| 南汇区| 平原县| 鱼台县| 达孜县| 蛟河市| 河间市| 黔南| 内乡县| 黔西县| 年辖:市辖区| 巫山县| 威远县| 双柏县| 灵石县| 井陉县| 城步| 吉木萨尔县| 平昌县| 桃江县| 高淳县| 永登县| 墨江| 宁晋县| 弥渡县| 东乡县| 宜都市| 汉阴县| 西城区| 金塔县| 容城县| 班戈县| 剑河县| 昌都县| 海门市| 曲周县| 大同县| 奉化市| 巴彦淖尔市| 太和县| 托克逊县|