Pages

Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Tuesday, March 18, 2014

How to install mysql on jboss as a module

first create the folder structure <jboss directory>/modules/com/mysql/main
copy the the mysql connector jar to the folder
thlen add module.xml file to the same folder and add the following to the 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.28.jar"/>            
  </resources>
  <dependencies>
     <module name="javax.api"/>
  </dependencies>
</module>

Note that the resource-root element's path should be the file name of the mysql connector jar

Now the final step

edit the standalone.xml file in standalone/configuration folder. then add the following in the drivers element.
<driver name="mysqlDriver" module="com.mysql">
                        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                    </driver>

note the mysqlDriver is the name of the driver and you can use it to configure the data source.

Wednesday, August 29, 2012

spring jdbc template with mysql

Required Libraries are,

commons-logging
spring-jdbc
spring-beans
spring-core
spring-tx
spring-asm
mysql-connector-java
spring-context
spring-context-support
spring-expression

You can do this simply by using maven. Just google maven dependencies for spring jdbc template and put the dependencies in your pom.xml file and you are good to go.

Let's see how to use jdbc template in spring to communicate with mysql database.

Create a model class named Book.


package mad.library.form;

public class Book {

private String name;
private String author;
private String category;

public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}

}

Now create the BookDataManager class as following.