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:
XML Version = "1.0" encoding = "UTF-8"?>
Update your login-conf.xml, here is an example for a
ConfigureDIndentityLoginmodule:
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.
->
HSQLDBREALM Attribute>
->
Properties>
attribute>
mbean>
depende>
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 ->
mbean>
depende>
mbean>
Name = "jboss: service = hypersonic"> mbean> server> 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 XML Version = "1.0" encoding = "UTF-8"?> Properties> attribute> depende> mbean> depende> mbean> server> Please compare the difference between the two documents, it is easy to write access to other databases, the main thing is the following Properties> attribute> mbean> 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 jboss-web> Web.xml content is XML Version = "1.0"?>
"- // Sun Microsystems, Inc.//dtd Web Application 2.3 // En" "http://java.sun.com/dtd/web-app_2_3.dtd"> web-app> 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 h3>
<%
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
XML Version = "1.0" encoding = "UTF-8"?>
Properties>
attribute>
depende>
mbean>
depende>
mbean>
server>
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
jboss-web>
Web.xml content is
XML Version = "1.0"?>
"- // Sun Microsystems, Inc.//dtd Web Application 2.3 // En"
"http://java.sun.com/dtd/web-app_2_3.dtd">
web-app>
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"%>
<%
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