The configuration of the database of JBoss3.0-Tomcat4.03 (take oracle as an example)

zhaozj2021-02-16  51

First, add classes12.zip to the classpath.

Second, please participate in the HSQLDB-Service.xml file to write an ORACLEDB-Service.xml file

Open the HSQLDB-Service.xml file under the Server / Default / Deploy directory, which is an example of implementing the database connection under jboss3.0_tomcat4.03, which is the following contents of the HSQL database:

Update your login-conf.xml, here is an example for a

ConfigureDIndentityLoginmodule:

SA

SA

jboss.jca: service = localtxcm, name = hsqldbds

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.

->

HSQLDBREALM

->

Defaultds

JDBC: HSQLDB: HSQL: // localhost: 1476

Org.hsqldb.jdbcdriver

sa

jboss.jca: service = rarDeployment, name = jboss localtransaction jdbc wrapper

jboss: service = hypersonic

0

50

15

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 sales ",

Bynothing (All Connections Are Equivalent, USUALLY IF Adapter Supports

Reausehentication ->

bycontainer

jboss.jca: service = CachedConnectionManager

jboss.security :service=jaassecuritymanager

Java: / TransactionManager

jboss.jca: service = rarDeployer

Name = "jboss: service = hypersonic">

1476

True default

false

Some instructions in use between , so remove this instructions after rewriting an XML file with the service of the Oracle database is OracleDB-Service.xml

Oracleds

JDBC: Oracle: Thin: @cuipeng: 1521: ORA8

Oracle.jdbc.driver.OracleDriver

system

manager

jboss.jca: service = rarDeployment, name = jboss localtransaction jdbc wrapper

0

50

15

bycontainer

jboss.jca: service = CachedConnectionManager

jboss.security :service=jaassecuritymanager

Java: / TransactionManager

jboss.jca: service = rarDeployer

Please compare the difference between the two documents, it is easy to write access to other databases, the main thing is the following

Oracleds

JDBC: Oracle: Thin: @cuipeng: 1521: ORA8

Oracle.jdbc.driver.OracleDriver

system

manager

jboss.jca: service = rarDeployment, name = jboss localtransaction jdbc wrapper

There is also the name of each part name name = ORACLEDS

Third, the connection of the test data (I use JSP)

You must write .war or .ear bag to test a simple approach is:

1. Establish an Oracle-Test.war directory in the deploy directory.

Second, establish a web-inf directory in the Oracle-Test.war directory, two files

JBoss-web.xml and web.xml

The content is

JBoss-web.xml content is

Web.xml content is

"- // Sun Microsystems, Inc.//dtd Web Application 2.3 // En"

"http://java.sun.com/dtd/web-app_2_3.dtd">

Third, establish a new file in Oracle-Test.War directory Index.jsp whose content is

<% @ Page ContentType = "Text / HTML"%>

<% @ page import = "java.sql. *, javax.sql.datasource, javax.naming.initialcontext"%>

Test Oracle DB

<%

InitialContext CTX = New InitialContext ();

DataSource DS = (Datasource) CTX.lookup ("java: / oracleds"); // Note Here and the previous

Connection conn = ds.getConnection (); statement stmt = conn.createstatement ();

ResultSet RS = Stmt.executeQuery ("SELECT * from Tab");

While (rs.next ()) {

Out.println (Rs.getstring ("TNAME") "
");

}

CONN.CLOSE ();

%>

Four, please visit http: // localhost: 8080 / Oracle-Test

Everything tests OK, if there is anything wrong, please refer to, I am also learning.

SQLSERVER database test

Create a sqlserverdb-service.xml file in the deploy directory.

The content is as follows

SQLServerDS

JDBC: Microsoft: SQLServer: // asen: 1433; databasename = infomag

com.microsoft.jdbc.sqlser.sqlserverdriver

sa

Bodaasen

jboss.jca: service = rarDeployment, name = jboss localtransaction jdbc wrapper

0

50

15

bycontainer

jboss.jca: service = CachedConnectionManager

jboss.security :service=jaassecuritymanager

Java: / TransactionManager

jboss.jca: service = rarDeployer

Third, the connection of the test data (I use JSP)

You must write .war or .ear bag to test a simple approach is:

First, establish a SQLServer-Test.war directory in the deploy directory.

Second, establish a web-inf directory in the SQLServer-Test.war directory, two files

JBoss-web.xml and web.xml

The content is

JBoss-web.xml content is

Web.xml content is

"- // Sun Microsystems, Inc.//dtd Web Application 2.3 // En"

"http://java.sun.com/dtd/web-app_2_3.dtd">

Third, establish a new file in the SQLServer-Test.war directory Index.jsp whose content is

<% @ Page ContentType = "Text / HTML"%>

<% @ page import = "java.sql. *, javax.sql.datasource, javax.naming.initialcontext"%>

Test SQL Server DB

<%

InitialContext CTX = New InitialContext ();

DataSource DS = (Datasource) CTX.lookup ("Java: / SqlSerVerDS);

Connection conn = ds.getConnection ();

Statement Stmt = conn.createstatement ();

ResultSet RS = Stmt.executeQuery ("SELECT * from user_infor");

While (rs.next ()) {

Out.println (rs.getstring (1) ");

}

CONN.CLOSE ();

%>

Http: // localhost: 8080 / SQLSerVer-test

Everything OK

turn out

TEST SQL Server DB

001

002

003

admin

转载请注明原文地址:https://www.9cbs.com/read-25261.html

New Post(0)