JBoss 7 Datasource with MySql DB
Hi Reader,
This is my second post. I am going to start with JBoss 7 Datasource implementation with JNDI and Properties file. Finally deploying war file in Eclipse IDE.
JAVA Configuration
We need to change the environmental system variable JAVA_HOME to C:\Java\jdk1.6.
For Ubutnu user install Java apt-get install openjdk-7-jdk
set Java using JAVA_HOME =/usr/lib/jvm/java-7-sun
JBoss 7 Installation
We can download JBoss 7 from below JBoss site
http://www.jboss.org/jbossas/downloads/
Download the Zip file.
SET JBOSS_HOME=C:\jboss-as-7.1.1.Final
C:\jboss-as-7.1.1.Final\bin>service.bat install
For Ubutnu users download JBoss 7 using below command
wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz
Finally unzip JBoss 7 and put in folder /usr/local/share/JBoss
tar xfvz jboss-as-7.1.1.Final.tar.gz
mv jboss-as-7.1.1.Final /usr/local/share/jboss
MySql Installation
We need to download MySql from the below site
http://dev.mysql.com/downloads/mysql
We can install MySql for Ubutnu users using below command
sudo apt-get install mysql-server
We can create database new database using below command
mysqladmin create <databasename>
Dumping Tables in MySql Database from DB Scripts
First we need to create the database in MySql DB.
eate Create database MyDB;
We can dump the tables in MySql databse from the DB Script using below command
mysql>use SatyaDB;
mysql>Source /usr/local/share/DB_Dump_file.sql;
We will get all the tables from the dump file into my newly created database.
Download Mysql Connector jar file
We need to download mysql-connector-java-5.1.24.bin.jar file using below link
http://www.java2s.com/Code/Jar/m/Downloadmysqlconnectorjava5124binjar.htm
JBoss 7 Configuration
In the very beginning we need to create a folder modules/com/mysql/main inside /usr/local/share/JBoss
Copy the mysql connector jar file into the modules/com/mysql/main folder.
Create another file module.xml file inside modules/com/mysql/main folder where we have copied the jar file.
module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.24.biationn.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
I am putting the connector jar file in the resource-root of resources inside module.xml file. In the module folder we have two files module.xml and JDBC library.
Properties File
Create a properties file in /usr/local/share and copy the satyaprop.properties file in the specific properties folder.
satyaprop.properties
JNDI_LOOKUP = java:/satyaDS01
Properties File Configuration
Setting up properties folder path in JBoss standalone.sh file.
-DCU.HOME=\/usr/local/share/properties \
JBoss 7 standalone.xml File Configuration
We need to register com.mysql module under the modules/com/mysql/main folder.
We need to add driver references in the standalone.xml ( /jboss 7/standalone/configuration)
<drivers>
<driver name="mysql" name="com.mysql">
<xa-datasource-class>
com.mysql.jdbc.jdbc2.optional.MySqlXADataSource
</xa-datasource-class>
</drivers>
Remaining setup I will continue in my next post.................
Hi Reader,
This is my second post. I am going to start with JBoss 7 Datasource implementation with JNDI and Properties file. Finally deploying war file in Eclipse IDE.
JAVA Configuration
We need to change the environmental system variable JAVA_HOME to C:\Java\jdk1.6.
For Ubutnu user install Java apt-get install openjdk-7-jdk
set Java using JAVA_HOME =/usr/lib/jvm/java-7-sun
JBoss 7 Installation
We can download JBoss 7 from below JBoss site
http://www.jboss.org/jbossas/downloads/
Download the Zip file.
SET JBOSS_HOME=C:\jboss-as-7.1.1.Final
C:\jboss-as-7.1.1.Final\bin>service.bat install
For Ubutnu users download JBoss 7 using below command
wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz
Finally unzip JBoss 7 and put in folder /usr/local/share/JBoss
tar xfvz jboss-as-7.1.1.Final.tar.gz
mv jboss-as-7.1.1.Final /usr/local/share/jboss
MySql Installation
We need to download MySql from the below site
http://dev.mysql.com/downloads/mysql
We can install MySql for Ubutnu users using below command
sudo apt-get install mysql-server
We can create database new database using below command
mysqladmin create <databasename>
Dumping Tables in MySql Database from DB Scripts
First we need to create the database in MySql DB.
eate Create database MyDB;
We can dump the tables in MySql databse from the DB Script using below command
mysql>use SatyaDB;
mysql>Source /usr/local/share/DB_Dump_file.sql;
We will get all the tables from the dump file into my newly created database.
Download Mysql Connector jar file
We need to download mysql-connector-java-5.1.24.bin.jar file using below link
http://www.java2s.com/Code/Jar/m/Downloadmysqlconnectorjava5124binjar.htm
JBoss 7 Configuration
In the very beginning we need to create a folder modules/com/mysql/main inside /usr/local/share/JBoss
Copy the mysql connector jar file into the modules/com/mysql/main folder.
Create another file module.xml file inside modules/com/mysql/main folder where we have copied the jar file.
module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.24.biationn.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
I am putting the connector jar file in the resource-root of resources inside module.xml file. In the module folder we have two files module.xml and JDBC library.
Properties File
Create a properties file in /usr/local/share and copy the satyaprop.properties file in the specific properties folder.
satyaprop.properties
JNDI_LOOKUP = java:/satyaDS01
Properties File Configuration
Setting up properties folder path in JBoss standalone.sh file.
-DCU.HOME=\/usr/local/share/properties \
JBoss 7 standalone.xml File Configuration
We need to register com.mysql module under the modules/com/mysql/main folder.
We need to add driver references in the standalone.xml ( /jboss 7/standalone/configuration)
<drivers>
<driver name="mysql" name="com.mysql">
<xa-datasource-class>
com.mysql.jdbc.jdbc2.optional.MySqlXADataSource
</xa-datasource-class>
</drivers>
Remaining setup I will continue in my next post.................
No comments:
Post a Comment