Preface
Jboss 4.0 is an open-source application server that uses HypersonicDB as its default database. However, developers may also need to use other types of databases except HypersonicDB. In this article, we will see how to configure other databases on Jboss.
Introduction
Jboss uses the JDBC configuration file to configure database connections. It provides data sources for access between ejbs and other J2EE applications. If you want to use a database other than HypersonicDB, You need to modify this configuration file. This article focuses on the following parts:
L Jboss EJB deployment descriptor
L Oralce Database Configuration
L MySQL Database Configuration
L Sysbase Database Configuration
L DB2 database configuration
L Infomix Database Configuration
Jboss EJB deployment descriptor
Standardjaws. xml (in X: jboss4serverdefaconf conf) is a standard deployment description file mapped to the CMP Entity EJB. It is used to configure the CMP Entity EJB. You can also use jaws. xml instead. You can copy this file to the META-INF directory in the ejb. jar file. This file is used to describe the following information:
L describes a data source and ing type.
L description of the EJB ing table
L description of the EJB finder Method
L description type ing
The data source here describes a JNDI name, which can be used to obtain a data source connection pool. Jboss4 uses HypersonicDB by default. If other data sources are used, you need to modify the jaws. xml file.
Standardjbosscmp-jdbc.xml (located in X: jboss4serverdefaconf conf) is the standard deployment description file for configuring the Jboss CMP container, and you can also replace it with a custom configuration file-jbosscmp-jdbc.xml. This file is also placed in the META-INF directory of the EJB. jar file. HypersonicDB is used as the database by default, which also needs to be modified here.
Oracle Database Configuration
Oracle has become a very popular enterprise-level database for its stability and reliability. To configure Oracle on Jboss, copy the JDBC driver of Oracle to ClassPath. Copy the JDBC driver to the server/default/lib directory. To use Oracle's transaction processing data source, we also need to copy/docs/examples/jca/oracle-xa-ds.xml to the/server/default/deploy directory. If you are using 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 & lt driver-class/& gt tag and & lt connection-url/& gt tag are set as follows:
Oracle OCI Type 2 Driver
Class: oracle. jdbc. driver. OracleDriver
URL: jdbc: oracle: oci8: @ & lt database & gt
Oracle OCI Thin Type 4 Driver
Class: oracle. jdbc. driver. OracleDriver
URL: jdbc: oracle: thin: @ & lt host & gt: & lt port & gt: & lt database & gt
Oracle oci xa Type 2 Driver
Class: oracle. jdbc. xa. client. OracleXADataSource
URL: jdbc: oracle: thin: @ & lt host & gt: & lt port & gt: & lt database & gt
Oracle OCI Type 2 Driver
Class: oracle. jdbc. driver. OracleDriver
URL: jdbc: oracle: oci8: @ & lt database & gt
In the Connection URL, & lt host & gt is the host name of the computer on which Oracle is installed, & lt port & gt is the port of the oracle database, and & lt database & gt is the database name. Next, we will modify the standardjaws. xml or jaws. xml configuration file and set the & lt datasource & gt and & lt type-mapping & gt elements as follows:
& Lt jaws & gt
& Lt datasource & gtjava:/OracleDS & lt/datasource & gt
& Lt type-mapping & gtOracle8 & lt/type-mapping & gt
& Lt/jaws & gt
Next, modify the standardjbosscmp-jdbc.xml or jbosscmp-jdbc.xml configuration file and set the & lt datasource & gt and & lt datasource-mapping & gt elements to use Oracle.
& Lt jbosscmp-jdbc & gt
& Lt defaults & gt
& Lt datasource & gtjava:/OracleDS & lt/datasource & gt
& Lt datasource-mapping & gtOracle8 & lt/datasource-mapping & gt
& Lt/defaults & gt
& Lt/jbosscmp-jdbc & gt
Finally, we need to modify the login-config.xml file to use Oracle. below is the & lt application-policy & gt element of the login-config.xml file:
& Lt application-policy name = "OracleDbRealm" & gt
& Lt authentication & gt
& Lt login-module code =
"Org. jboss. resource. security. ConfiguredIdentityLoginModule"
Flag = "required" & gt
& Lt module-option name = "principal" & gtsa & lt/module-option & gt
& Lt module-option name = "userName" & gtsa & lt/module-option & gt
& Lt module-option name = "password" & gt & lt/module-option & gt
& Lt module-option name = "managedConnectionFactoryName" & gt
Jboss. jca: service = LocalTxCM, name = OracleDS
& Lt/module-option & gt
& Lt/login-module & gt
& Lt/authentication & gt
& Lt/application-policy & gt
Modified oracle-ds.xml, standardjaws. xml, standardjbosscmp-jdbc.xml, and
After the login-config.xml file, you can use Oracle in Jboss4.
MySQL Database Configuration
MySQL is an open-source database that is used by many open-source projects and small organizations. To use MySQL in Jboss4, you must first put the JDBC driver of MySQL into CLASSPATH. Similarly, copy it to the/server/default/lib directory, and then copy/docs/examples/jca/mysql-ds.xml to the/server/default/deploy directory. Modify the mysql-ds.xml file, set & lt driver-class/& gt to com. mysql. jdbc. Driver, and then set & lt connection-url/& gt to <