Configuring JBoss 4 JDBC connection JDBC

xiaoxiao2021-03-06  119

The developer version of JBoss 4.0 is an open source application server, and he takes HyperSonicDB as his default database. However, developers may also use a database other than HyperSonicDB, in which we will see how to configure other databases on JBoss.

Introduction JBoss4.0 uses a JDBC profile to configure database connections, which provides data sources for EJBs and other J2EE applications. If you want to use the database other than HypersonicDB, you will modify this profile. This article will focus on the following parts:

JBoss EJB Deployment Descriptor Oralce Database Configuring the configuring the SYSBASE database configures the configuration of the configuration of the DB2 database in infomix database configuration

JBoss's EJB deployment descriptor Standardjaws.xml (in x: / jboss4 / server / default / conf) is a standard deployment description file that maps CMP entity EJB. It is used to configure CMP entity EJB, you can also use jaws.xml instead. You can copy this file Copy to the meta-inf directory in the EJB .jar file. This file is used to describe the following information:

Describe a data source and mapping type. Describe the table description type mapping of EJB mapping

The data source here is a JNDI name that can be obtained through this JNDI to obtain a data source connection pool. JBoss4 default data sources are HypersonicDB. If you need to use other data sources, you need to modify the jaws.xml file.

Standardjbosscmp-jdbc.xml (in x: / jboss4 / server / default / conf) is a standard deployment description file configured for the JBoss CMP container, you can also use a custom profile -jbosscmp-jdbc.xml instead of it. This file is also placed in the meta-INF directory of the EJB.jar file. It is also a need to modify it by default or hypersonicDB as a database.

Oracle database configuration

Oracle is a very popular enterprise database with its operational stability and reliability. To configure Oracle on JBOSS, what is the first thing we have to do is to copy the Oracle's JDBC driver to ClassPath. We copied this JDBC driver to the server / default / lib directory. In order to use Oracle's transaction processing data source we must also copy /DOCS/examples/jca/oracle-xa-ds.xml to the / Server / Default / Deploy directory. If you use a non-transactional data source, copy the /DOCS/examples/jca/oracle-ds.xml file to the / Server / Default / Deploy directory.

Next, we need to modify the Oracle-de.xml configuration file. The Tags and tag settings are as follows:

Oracle OCI Type 2 Driver

Class: Oracle.jdbc.driver.Oracledriver

URL: JDBC: Oracle: OCI8: @

Oracle OCI Thin Type 4 Driver

Class: Oracle.jdbc.driver.Oracledriver

URL: JDBC: Oracle: Thin: @ : : Oracle OCI XA Type 2 Driver

Class: Oracle.jdbc.xa.client.OraclexADataSource

URL: JDBC: Oracle: Thin: @ : : Oracle OCI Type 2 Driver

Class: Oracle.jdbc.driver.Oracledriver

URL: JDBC: Oracle: OCI8: @

In the Connection URL is the computer host name to install Oracle, is the port of the Oracle database, is the database name. Next, we will modify the Standardjaws.xml or Jaws.xml configuration file, and use the and elements as below:

java: / oracleds Oracle8

Next, modify the StandardJbossCMP-JDBC.XML or JBOSSCMP-JDBC.XML configuration file, set and elements to use Oracle.

java: / oracleds Oracle8

Finally, we need to modify the login-config.xml file to use Oracle, below is the element of the login-config.xml file:

"Org.jboss.Resource.security.configuredIndityLoginmodule"

Flag = "required"> sa sa jboss.jca: service = localtxcm, name = oracleds

Modified Oracle-DS.xml, Standardjaws.xml, StandardJbosscmp-JDBC.XML, and later you can use Oracle in JBoss4.

MySQL database configuration mysql is an open source database, with many open source projects and small communities are using it. To use MySQL in JBoss4, first you want to put the mysql JDBC in the classpath. Similarly, copy it to the / server / default / lib directory, copy /DOCS/examples/jca/mysql-ds.xml to the / Server / Default / Deploy directory. Modify the mysql-ds.xml file, set to set the set to JDBC: mysql: // / , where / > Is the database hostname is the database name. Then you need to set the and elements of StandardJaws.xml or Jaws.xml files:

java: / mysqlds mysql also need of StandardJbossCMP-JDBC.XML or JBossCMP-JDBC.XML files And the element is set to the following: java: / mysqlds mysql Finally modify the login-config.xml file to use mysql:

Flag = "required"> sa sa jboss.jca: service = localtxcm, name = mysqlds modification MySQL-DS.XML, Standardjaws.xml, Standardjbosscmp-JDBC.XML, and Login-Config.xml files can be used on JBOSS to use mysql.

SYSBASE database configuration

Sybase Adaptive Server Enterprises (ASE) is the Sysbase's database server. ASE can be used on UNIX and Linux platforms. Similarly, we have to drive its database to the classpath, copy it into the / server / default / lib directory, then copy the /DOCS/examples/jca/sybase-ds.xml to / Server / Default / Deploy directory . Modify the Sybase-DS.xml file to set to com.sybase.jdbc2.jdbc.sybdriver, set to JDBC: Sybase: TDS: : / < Database>, where is the host name, port name, and database name, respectively. Also need to modify the and elements of Standardjaws.xml or Jaws.xml files: java: / sybaseds Sybase < / jaws> Remove the and elements of StandardJbosscmp-JDBC.XML or JBossCMP-JDBC.XML files:

java: / sybaseds Sybase

Finally modify the login-config.xml file to use the SYSBASE database. Set Element:

"Org.jboss.resource.security.configuredIndityLoginmodule" flag = "required">

SA sa

jboss.jca: service = localtxcm, name = Sybased

Modified Sybase-DS.xml, StandardJaws.xml, StandardJbosscmp-jdbc.xml, and login-config.xml files Use sysbase in JBOSS.

DB2 Database Configuration IBM's DB2 is a perfect, easy to use the database server, which can be used on Linux, UNIX, and Windows platforms. Use DB2 on JBoss4 as long as you copy db2java.zip to the / Server / Default / Lib directory. Then copy the /DOCS/examples/jca/db2-ds.xml to the / server / default / deploy directory, then modify the element bits com.ibm.db2.jdbc.app.db2driver, Elements is JDBC: DB2: where the element represents the database service name.

Java: / db2ds

DB2

Here is the corresponding StandardJbosscmp-JDBC.XML (or JBossCMP-JDBC.XML) file:

Java: / db2ds db2 Last in the login-config.xml file Plus the following:

Flag = "required"> SA

"Username"> SA

JBoss.jca: service = localtxcm, name = db2ds Finish the above configuration can use DB2 on JBOSS

Informix database Configuration IBM's InfoxMix database server is used as a data warehouse, analysis and reporting. Use the Informix database on JBoss4, first copy it to the / server / default / lib directory, then copy / serve / default / deploy In the directory, if you use a transaction (XA) JDBC, copy the /DOCS/examples/jca/informix-xa-ds.xml file. The next step is to modify this Informix-DS.xml file, set the element to: com.informix.jdbc.iFxDriver Set element to jdbc: Informix-SQLI: / / : : informixserver = , where , , represents the database hostname, database port, and database service name, respectively. Then modify the and element of Standardjaws.xml or Jaws.xml file: java: / informixds InformixDB

Set the and elements in the StandardJbuscmp-jdbc.xml or jbosscmp-jdbc.xml file: java: / informixds < DataSource-mapping> InformixDB

Finally, add element in the login-config.xml file:

sa

sa jboss.jca: service = localtxcm Name = informixds You can use the Informix database in JBoss4. Conclusion JBoss4 uses the Hypersonic database by default, but if you see us as long as you have a simple modification of several configuration files, you can use the popular other databases on the market.

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

New Post(0)