JBoss Community

Connect to MySQL without Datasource in JBoss AS 7.1

created by Pradeep Kumar in Datasource Configuration - View the full discussion

Hi,

 

I am using JBoss AS 7.1 and am trying to connect to MySQL database without creating a datasource name. Unfortunately, while running the client program,  the Bean throws ClassNotFoundException

 

Here is what I did :

I have put the mysql-connector-java-5.1.18-bin.jar in JBOSS_HOME/modules/com/mysql/jdbc/main . And created a module.xml file with the following contents :

 

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql.jdbc">
  <resources>
    <resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
  </dependencies>
</module>

 

Then updated the standalone.xml file with the following line under the drivers node

 

<driver name="mysql" module="com.mysql"/>

 

Here is my Bean Code :

Reply to this message by going to Community

Start a new discussion in Datasource Configuration at Community