The standard distribution of PXE relies on a Hibernate
data access layer to provide persistence facilities. Hibernate can support most major databases; consequently, PXE can in theory support most major databases.
By default, the PXE distribution uses an embedded HypersonicSQL
instance to provide persistence facilities. In order to use a different database, one must generally:
- install the database
- populate the database with PXE's schema (schema files are found in etc/*.sql of the PXE distribution)
- install the database's JDBC driver in PXE's lib/ directory
- modify the hibernate.properties and pxe-config.xml files in the etc/ directory of the PXE distribution
HypersonicSQL (HSQL
) is included with the PXE distribution and is the default database used by the PXE stand-alone server. To use this database, simply leave the configuration files as is. More precisely, etc/hibernate.properties and etc/pxe-config.xml should look like:
hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect
.
.
.
<kmodule name="fivesight.pxe:mod=PxeDB" class="ModJdbcDS">
<attribute name="dataSourceName">pxe-ds</attribute>
<attribute name="transactionManagerName">TransactionManager</attribute>
<attribute name="driver">org.hsqldb.jdbcDriver</attribute>
<attribute name="username">sa</attribute>
<attribute name="password"></attribute>
<attribute name="url">jdbc:hsqldb:<pxe-home/>/hsql/pxeDb</attribute>
<attribute name="poolMax">1</attribute>
<attribute name="poolMin">1</attribute>
</kmodule>
.
.
.
Note that with HypersonicSQL it is important to set the poolMax property to 1 in order to avoid database collisions: HypersonicSQL does not support transaction isolation!
In order to use MySQL with PXE, one must follow the following steps:
- install / locate a MySQL (v4.0 or v4.1) server installation
- configure said MySQL server to accept TCP connections (NOTE: this is not the default for MySQL!)
- create / designate a user (pxe-user) on the MySQL server for use by PXE
- create a database (pxe-db) for PXE's use on the MySQL server
- populate the pxe-db with the PXE schema (found in etc/mysql.sql in the PXE distribution)
- grant the pxe-user read/write access to the pxe-db
- obtain the MySQL J-Connect JDBC driver (v3.x)
and copy it to PXE's lib/ directory
- Modify PXE's etc/hibernate.properties file to resemble:
hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
- Modify PXE's etc/pxe-config.xml file to resemble:
.
.
.
<kmodule name="fivesight.pxe:mod=PxeDB" class="ModJdbcDS">
<attribute name="dataSourceName">pxe-ds</attribute>
<attribute name="transactionManagerName">TransactionManager</attribute>
<attribute name="driver">com.mysql.jdbc.Driver</attribute>
<attribute name="url">jdbc:mysql://localhost/pxe-db</attribute>
<attribute name="username">pxe-user</attribute>
<attribute name="password"></attribute>
<attribute name="poolMax">10</attribute>
<attribute name="poolMin">5</attribute>
</kmodule>
.
.
.