Skip to main content

DataSources with Sun Java System Creator and JBoss

Posted by ddevore on April 19, 2006 at 2:15 PM PDT

We are currently using Creator to create a testing and QA front end for the enterprise application we are developing. After success with working with services we finally needed to hit a configuration database to show all the configuration options available to different applications and users.

The Data Source

We started by putting 2 simple drop down on the screen and tried to attach a data source to them. Since we are using MySQL for this configuration database we had to add the data source, which is very simple. Select the Servers tab and right click on the Data Sources and you will see an Edit... button to the right of the drop down for the Server Type select this and in the dialogue which comes up select New on the bottom left. Then simply browse to the jar file for the data source you are adding, for us it is mysql-connector-java-3.1.12-bin.jar, and select Open. Give it a name and for MySQL put in com.mysql.jdbc.Driver for the Driver Class Name, if you select suggest it will suggest an older driver named In the URL Template put in the following jdbc:mysql://#HOSTNAME:3306/#DATABASE changing the 3306 to the appropriate port and select close. Give the data source a name and fill in the fields with the proper information and select Add.

The JBoss XML

For JBoss to work correctly with your datasources from Creator you need to tell JBoss the references for the data sources. To do this you need a jboss-web.xml file in the creator_project/web/WEB-INF directory. Create this file, or download below, and put it in the creator_project/web/WEB-INF directory.

<?xml version="1.0" encoding="UTF-8"?>

Make sure to change the myDataSource name to the actual jndi name in your JBoss configuration. Don't forget the "/" in the front of the datasource without this it will not work correctly.

The Binding

Once this is done you are ready to bind the data to the drop down. Simply put a drop down on your page and right click in and select Bind to Data.. Select Add Data Provider and select the proper table from your data source. Make sure that it selected the correct value and display fields and select OK.

Clean and Build

If you have not gotten any errors up to this point you should be able to clean and build the project and deploy to your JBoss directory. If you get errors under deploying make sure you set the data source correctly in JBoss Databases with JBoss and setup JBoss to work with creator How to setup JBoss to work with Sun Java Studio Creator

Happy Creating

Download jboss-web.xml file

Related Topics >>