Specifying a datasource

A datasource is, mainly, a database plus a driver plus a connection pool. By default, jboss uses the Hypersonic datasource. To add another datasource, you have to declare it as a JMX MLet: see Chapter 3.

The second ARG of this MLet is the JNDI name of the datasource, i.e. the name you have to use to access it. To tell JAWS to use this datasource, simply add in your jaws.xml file a <datasource> tag with the JNDI name in it.

According to the type of the database, you probably also want to specify a type mapping for this datasource. A type mapping tells JAWS which jdbc types, which sql types to use for the storage of your cmp fields. You just have to add a <type-mapping> tag with the name of the type mapping in it. Type mappings for the most common databases are already defined in jboss in a file called standardjaws.xml. Their names are listed here:

For instance, if you want to use the Postgres Database that you have deployed in jboss.conf under the name InstantDB, this is how your jaws.xml file should look like:

 
 <jaws>
   <datasource>InstantDB</datasource>
   <type-mapping>InstantDB</type-mapping>
   ...
 </jaws>
  

If none of the predefined type mappings satisfies your needs, you can define your own type-mapping.