-
1. Re: configure jboss 4.0 with MySql server
juha Sep 9, 2003 9:44 AM (in response to shehan)4.0 is a developer's release so you probably should not be using it yet.
-- Juha -
2. Re: configure jboss 4.0 with MySql server
shehan Sep 10, 2003 1:06 AM (in response to shehan)Anyway, if somebody has done it...plsss tell me how u did that
-
3. Re: configure jboss 4.0 with MySql server
naveen1975 Sep 18, 2003 2:55 AM (in response to shehan)I am a new bie to Jboss 4.0, but after spending come time and going thru documentation.. i got it worked.
Here are the steps:
1. Create the mysql-ds.xml file with the following config info.
<?xml version="1.0" encoding="UTF-8"?>
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://localhost/db</connection-url>
<driver-class>org.gjt.mm.mysql.Driver</driver-class>
<min-pool-size>5</min-pool-size>
</local-tx-datasource>
2. Copy this file into the default/deploy directory of jboss.
3. Also get the latest version of Mysql JCA Conector from mysql.com. It is named 'mysql-connector-java-3.0.8-stable-bin.jar'.
4. Copy this file into deploy/lib directory.
Now you are ready to access the database. Here is the a small snippet to access database in some session bean.
Get the datasource.
Note: check the jndi name in the above configuration.
InitialContext ctx = new InitialContext();
//Load mysql datasource
ds = (DataSource) ctx.lookup("java:/MySqlDS");
System.out.println("Data source initialized.");
.
.
.
Access the database:
java.sql.Connection conn = ds.getConnection();
java.sql.Statement stmt = conn.createStatement();
String sql = "SELECT name FROM trail";
java.sql.ResultSet rs = stmt.executeQuery(sql);
while(rs.next())
data.addElement(rs.getString(1));
conn.close();
I hope that helps.
Naveen.