MySQL is an open source database used by many open source projects and small organizations. To use JBoss 4.0 with MySQL, we first need to put the MySQL driver classes into the CLASSPATH. Copy the .jar file mysql-connector-java-3.0.9-stable-bin.jar to the /server/default/lib directory.
To use the MySQL data source, copy /docs/examples/jca/mysql-ds.xml to the /server/default/deploy directory. Modify the mysql-ds.xml configuration file by setting
Next, we need to set the
We also need to set the
Finally, we modify login-config.xml with MySQL database settings. Add the following
jboss.jca:service=LocalTxCM,name=MySqlDS
By modifying the mysql-ds.xml, standardjaws.xml, standardjbosscmp-jdbc.xml, and login-config.xml files, the JBoss 4.0 server is configured to be used with a MySQL database.
In Client:
Hashtable ht=new Hashtable();
ht.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
ht.put(InitialContext.PROVIDER_URL,"jnp://localhost:1099");
ht.put(InitialContext.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
initialContext = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource) initialContext.lookup("java:MySqlDS");
java.sql.Connection conn = ds.getConnection();
// do the necessary database operations on connection.
Troubleshooting:
---------------------
javax.naming.NamingException: MySql not bound.
Then make sure that you have following entry in mySql-ds.xml:
Similarly for configuring oracle datasource in jboss:
----------------------------------------------------------------
Oracle Configuration
Oracle is a very popular enterprise database used for its performance and reliability. To configure JBoss 4.0 with Oracle, we first need to put Oracle's driver classes in the CLASSPATH. Copy Oracle's JDBC driver .zip file /jdbc/lib/classes12.zip to the server/default/lib directory.
To use Oracle's transactional (XA) data source, copy /docs/examples/jca/oracle-xa-ds.xml to the /server/default/deploy directory. To configure with the non-XA data source, copy /docs/examples/jca/oracle-ds.xml instead, to /server/default/deploy dir.
Next, we need to modify the oracle-ds.xml configuration file. The
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 setting,
Next, we modify the standardjaws.xml or jaws.xml configuration file. Set the
Next, we modify the standardjbosscmp-jdbc.xml or jbosscmp-jdbc.xml configuration file, setting the
Finally, we need to modify login-config.xml to use Oracle. Add the following
jboss.jca:service=LocalTxCM,name=OracleDS
By modifying the oracle-ds.xml, standardjaws.xml, standardjbosscmp-jdbc.xml, and login-config.xml files, the JBoss 4.0 server is configured to be used with a Oracle database.
No comments:
Post a Comment