Steven Webster wrote:
> I'm having a real hard time trying to get JBoss working with MySQL;
> reading through the list archives, all I can really ascertain is that
> the docs are not necessarily correct with regards to setting up JBoss.
>
> Has anyone successfully setup JBoss with MySql, that could perhaps
> send me the various entries they've made in the properties, conf and
> jcml files, to get things working ? I've got the driver installed ok,
> and checked it works with some simple JDBC client code (non EJB code).
I just got this working this week with the help of people on this list.
I am using JBoss 2.0. For newer versions check the documentation. But
for JBoss2.0, I made the following changes:
1) jboss.conf:
jdbc.drivers=org.hsql.jdbcDriver,org.enhydra.instantdb.jdbc.idbDriver,org.gjt.mm.mysql.Driver
Note: Although I just saw Danch say in his latest email that this is not
needed, "Do Nothing to jboss.properties or jboss.conf".
2) jboss.jcml:
<mbean name="DefaultDomain:service=XADataSource,name=mySQL">
<attribute name="Properties"></attribute>
<attribute
name="URL">jdbc:mysql://www.host_name_here.com:3306/mls</attribute>
<attribute name="GCMinIdleTime">1200000</attribute>
<attribute name="JDBCUser">user_goes_here</attribute>
<attribute name="MaxSize">10</attribute>
<attribute name="Password">password_goes_here</attribute>
<attribute name="GCEnabled">false</attribute>
<attribute name="InvalidateOnError">false</attribute>
<attribute name="TimestampUsed">false</attribute>
<attribute name="Blocking">true</attribute>
<attribute name="GCInterval">120000</attribute>
<attribute name="IdleTimeout">1800000</attribute>
<attribute name="IdleTimeoutEnabled">false</attribute>
<attribute name="LoggingEnabled">false</attribute>
<attribute name="MaxIdleTimeoutPercent">1.0</attribute>
<attribute name="MinSize">0</attribute>
</mbean>
3) In my session bean:
// Get database connection from pool
Connection conn = null;
Statement stmt = null;
ResultSet set = null;
try {
DataSource ds = (DataSource)(new InitialContext()).lookup(
"java:/mySQL");
conn = ds.getConnection();
set = stmt.executeQuery(query);
while (set.next()) {
..... sql processing
}
}
catch (SQLException e){
System.out.println("SQL statement exception");
}
catch (javax.naming.NamingException e){
System.out.println("NamingException");
}
finally {
if (conn != null) try {conn.close();}catch (SQLException ignore)
{}
if (stmt != null) try {stmt.close();}catch (SQLException ignore2)
{}
if (set != null) try {set.close();}catch (SQLException ignore3)
{}
}
4) In mySQL make sure that you grant the right permissions to the user
and allow the right host.
Hope this helps,
Brian
--
Brian Elliott
Unplugged Systems
[EMAIL PROTECTED]
http://www.unpluggedsystems.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user