The configuration of the database of JBoss3.0-Tomcat4.03 (Take Oracle as an example) 1. Add classes12.zip to classpath. Second, please resume 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 in which the database connection is implemented under jboss3.0_tomcat4.03, It is the following contents of the HSQL database: XML Version = "1.0" encoding = "UTF-8"?>
sa module -Ption> sa module-option> module-option> 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 HsqlDbRealm attribute> ->
DefaultDS attribute> jdbc: hsqldb: hsql: / / localhost: 1476 config-property> org.hsqldb.jdbcDriver config-property> SA config-protety> config-property> profment> attribute> < ! - Below here are advanced properties -> <- hack -> jboss.jca:! service = RARDeployment, name = JBoss LocalTransaction JDBC Wrapper depends> < Depends> jboss: service = hypersonic depende>
Mbean> depends> <-! Embedded mbean -> 0 attribute> 50 attribute> 5000 attribute> 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) -> ByContainer attribute> mbean> depends> < depends optional-attribute-name = "CachedConnectionManager"> jboss.jca: service = CachedConnectionManager depends> jboss.security:service=JaasSecurityManager depends>
Java: / TransactionManager Attribute>
jboss.jca: service = rarDeployer dependends>
mbean>
1476 attribute> True attribute> < Attribute name = "database"> default attribute> false attribute> mbean> server> in some instructions in use between , so Remove this instructions after rewriting an XML file for the service of the Oracle database is OracleDB-Service.xml XML Version = "1.0" eNCoding = "UTF-8"?>
OracleDS attribute> jdbc: oracle: thin: @ CUIPENG: 1521: ORA8 config-protety> Oracle.jdbc.driver.OracleDriver config-property> system config-protety> manager config-property> profitties> < / attribute> jboss.jca: service = RARDeployment, name = JBoss LocalTransaction JDBC Wrapper depends> mbean> depends>
0 attribute> 50 attribute> 5000 attribute> 15 attribute> ByContainer attribute> mbean> depends> jboss.jca: service = CachedConnectionManager depends>
jboss.security:service=JaasSecurityManager depends> java: / TransactionManager attribute>
jboss.jca: service = rarDeployer dependends>
mbean>
server> Please compare the difference between the two files, it is easy to write the access service of other databases. The main thing is the following part of the
Oracleds attribute> CONFIG-PROPERTY NAME = "ConnectionURL" type = "java.lang.string"> JDBC: Oracle: Thin: @cuipeng: 1521: ORA8 config-protety> Oracle.jdbc.driver.OracleDriver config-protety> system config-protety> manager config-property> properties> attribute> jboss.jca: service = RARDeployment, name = JBoss localtransaction jdbc wrapper depende> mbean> is also the name of each part name Name = ORACLEDS three, the connection of the test data (I use JSP) You must write .war or .ear bag to test one The simple practice is: 1. Establish an Oracle-Test.war directory in the deploy directory. Second, establish a web-inferry in the Oracle-Test.war directory, two files jboss-web.xml and web.xml content are the jboss-web. > Web.xml content is xml version = "1.0"?> web-app> 3, 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 Front Corresponding 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 All test OK, if there is anything wrong, please refer, I am also learning. This is a quick configuration method, I have some time I will show every property to everyone.