JFox(J2EE Application Server Implementation Project)

Last Modified: 2003.12.03

JFox DataSource


JFox datasource supports all databases that can provide XA specification drivers, now almost all of databases have already provided XA drivers, including Microsoft SQL Server, JDBC driver for SQL Server can be downloaded from Microsoft web site.

To add a datasource, just in file %JFOX_HOME%/conf/jfox-conf.xml add a MX element as below:

  <MX CLASSNAME="org.huihoo.jfox.mx.TxDataSourceServiceMX"

OBJECTNAME=":comp=TxDataSourceServiceMX">

    <METHOD NAME="mx_setDsName">

      <ARG TYPE="java.lang.String">TestDataSource</ARG>

    </METHOD>

    <METHOD NAME="mx_setDbUrl">

      <ARG TYPE="java.lang.String">jdbc:mysql://localhost/test</ARG>

    </METHOD>

    <METHOD NAME="mx_setUser">

      <ARG TYPE="java.lang.String">root</ARG>

    </METHOD>

    <METHOD NAME="mx_setPassword">

      <ARG TYPE="java.lang.String"></ARG>

    </METHOD>

    <METHOD NAME="mx_start"></METHOD>

  </MX>

This will create a MySql datasource named TestDataSource. Datasource name is not only used as the one and only datasource flag, but also used in jndi name. The JNDI name of %DS_NAME%'s datasource is /datasource/%DS_NAME%. Like the Datasource set as above, it can be got through ctx.lookup("datasource/TestDataSource").

To different datasource, there are different URL as below:
mysql: jdbc:mysql://localhost/test
Oracle: jdbc:oracle:thin:@localhost:1521:yang
DB2: jdbc:db2://localhost;databaseName=SAMPLE
MSSQL Server: (must setup selectMethod =cursor)

jdbc:microsoft:sqlserver://localhost:1433; selectMethod =cursor;databaseName=db

Notification: To make MSSQL Server support XA JDBC driver, you need to run a procedure on database server. You can know the exact operations by reading the document of JDBC driver for MSSQL Server which can be downloaded from Microsoft web site.