JPOX
JPOX
 Project  |  Ver 1.1  |  Ver 1.2  |  JDO  |  JPA  |  Guides  |  Tools
1.2 | Persistence | JDO ORM | JPA ORM | Runtime | JDO Runtime | JPA Runtime | Extensions | Developer
JPOX Runtime
RDBMS Datastores
DB4O Datastore
RDBMS Datastores

JPOX supports persisting objects to RDBMS datastores (using the jpox-rdbms plugin). It supports the vast majority of RDBMS products available today. JPOX communicates with the RDBMS datastore using JDBC. RDBMS systems accept varying standards of SQL and so JPOX will support particular RDBMS/JDBC combinations only, though clearly we try to support as many as possible.

By default when you create a PersistenceManagerFactory (PMF) to connect to a particular datastore JPOX will automatically detect the datastore adapter to use and will use its own internal adapter for that type of datastore. If you find that either JPOX has incorrectly detected the adapter to use, or that there is some issue with the internal adapter, you can override the default behaviour. Please refer to the Database Adapter Extension Guide for details.

The table below shows the versions of RDBMS and JDBC driver that JPOX has been tested with

Compatibility
RDBMS NameRDBMS VersionJDBC NameJDBC Version
3.23mysql-connector-java3.0
4.0mysql-connector-java3.0.16, 3.1.12
4.1mysql-connector-java3.0.16, 3.1.12
5.0mysql-connector-java3.1.12
MS SQL Server2000WindowsMicrosoft SQL Server JDBC Driver
2005WindowsMicrosoft SQL Server JDBC Driver
8JDBCojdbc14.jar and/or classes12
9JDBCojdbc14.jar and/or classes12
10.2JDBCojdbc14.jar (Oracle JDBC driver 10.2)
12.5JConnect5.5
15.0JConnect6.0.5
1.7HSQLDB1.7
1.8HSQLDB1.8
H21.0H21.0
McKoi1.0.3Mckoi JDBC Driver1.0
7.3PostgreSQL7.3
7.4PostgreSQL7.4
8.0PostgreSQL8.0
8.1PostgreSQL8.1
8.2PostgreSQL8.1
1.1.3 (+ PostgreSQL 8.1)PostGIS + PostgreSQL1.1.6, 1.2.0
1.1.4 (+ PostgreSQL 8.1)PostGIS + PostgreSQL1.1.6, 1.2.0
1.1.5 (+ PostgreSQL 8.1)PostGIS + PostgreSQL1.1.6, 1.2.0
1.1.6 (+ PostgreSQL 8.1)PostGIS + PostgreSQL1.1.6, 1.2.0
1.2.0 (+ PostgreSQL 8.1)PostGIS + PostgreSQL1.1.6, 1.2.0
Pointbase
10.0Derby10.0
10.1Derby10.1
10.2Derby10.2
DB208.01IBM DB2 JDBC 2.0 Type 208.01
08.02IBM DB2 JDBC 2.0 Type 208.02
DB2 UDB for AS/400 v5.2AS/400 Toolbox for Java JDBC Driver05.02
Firebird1.5.1Firebird1.5.0
SAPDB / MaxDB7.6.0MaxDB JDBC Driver7.6.0
Informix11.xInformix JDBC3.0

If you have success with any other combinations for the above RDBMS or indeed with any other RDBMS, please let us know so we can update our compatibility guide. We only show here what we have either tried ourselves or what has been reported as successful.



DB2

To specify DB2 as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)

javax.jdo.option.ConnectionDriverName=COM.ibm.db2.jdbc.app.DB2Driver
javax.jdo.option.ConnectionURL=jdbc:db2:'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'

#DB2network driver
#javax.jdo.option.ConnectionDriverName=COM.ibm.db2.jdbc.net.DB2Driver
#javax.jdo.option.ConnectionURL=jdbc:db2://hostname:port//dbname
                
MySQL

MySQL is supported as an RDBMS datastore by JPOX with the following provisos

  • INNODB tables must be used since it is the only table type that allows foreign keys etc at the moment
  • JDOQL.isEmpty()/contains() will not work in MySQL 4.0 (or earlier) since the query uses EXISTS and that is only available from MySQL 4.1
  • MySQL on Windows MUST specify org.jpox.identifier.case as "LowerCase" since the MySQL server stores all identifiers in lowercase BUT the mysql-connector-java JDBC driver has a bug (in versions up to and including 3.1.10) where it claims that the MySQL server stores things in mixed case when it doesnt
  • MySQL 3.* will not work reliably with inheritance cases since JPOX requires UNION and this doesn't exist in MySQL 3.*
  • MySQL before version 4.1 will not work correctly on JDOQL Collection.size(), Map.size() operations since this requires subqueries, which are not supported before MySQL 4.1.
  • If you receive an error "Incorrect arguments to mysql_stmt_execute" then this is a bug in MySQL and you need to update your JDBC URL to append "?useServerPrepStmts=false".
  • MySQL throws away the milliseconds on a Date and so cannot be used reliably for Optimistic locking using strategy "date-time" (use "version" instead)
  • You can specify "BLOB", "CLOB" JDBC types when using MySQL with JPOX but you must turn validation of columns OFF. This is because these types are not supported by the MySQL JDBC driver and it returns them as LONGVARBINARY/LONGVARCHAR when querying the column type

To specify MySQL as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)

javax.jdo.option.ConnectionDriverName=com.mysql.jdbc.Driver
javax.jdo.option.ConnectionURL=jdbc:mysql://'host':'port'/'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
                
MS SQL Server

MS SQL Server is supported as an RDBMS datastore by JPOX with the following proviso

  • MS SQL 2000 does not keep accuracy on datetime datatypes. This is an MS SQL 2000 issue. In order to keep the accuracy when storing java.util.Date java types, use int datatype.

To specify MS SQL as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)

Microsoft SqlServer 2005 JDBC Driver (Recommended)

javax.jdo.option.ConnectionDriverName=com.microsoft.sqlserver.jdbc.SQLServerDriver
javax.jdo.option.ConnectionURL=jdbc:sqlserver://'host':'port';DatabaseName='db-name';SelectMethod=cursor
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
                

Microsoft SqlServer 2000 JDBC Driver

javax.jdo.option.ConnectionDriverName=com.microsoft.jdbc.sqlserver.SQLServerDriver
javax.jdo.option.ConnectionURL=jdbc:microsoft:sqlserver://'host':'port';DatabaseName='db-name';SelectMethod=cursor
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
                
Oracle

To specify Oracle as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc) ... you can also use 'oci' instead of 'thin' depending on your driver.

javax.jdo.option.ConnectionDriverName=oracle.jdbc.driver.OracleDriver
javax.jdo.option.ConnectionURL=jdbc:oracle:thin:@'host':'port':'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
                
Sybase

To specify Sybase as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)

javax.jdo.option.ConnectionDriverName=com.sybase.jdbc2.jdbc.SybDriver
javax.jdo.option.ConnectionURL=jdbc:sybase:Tds:'host':'port'/'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
                
HSQLDB

HSQLDB is supported as an RDBMS datastore by JPOX with the following proviso

  • Use of batched statements is disabled since HSQLDB has a bug where it throws exceptions "batch failed" (really informative). Still waiting for this to be fixed in HSQLDB
  • Use of JDOQL/JPQL subqueries cannot be used where you want to refer back to the parent query since HSQLDB up to and including version 1.8 don't support this.

To specify HSQL as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)

javax.jdo.option.ConnectionDriverName=org.hsqldb.jdbcDriver
javax.jdo.option.ConnectionURL=jdbc:hsqldb:hsql://'host':'port'/'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
                
H2

H2 is supported as an RDBMS datastore by JPOX

To specify H2 as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)

javax.jdo.option.ConnectionDriverName=org.h2.Driver
javax.jdo.option.ConnectionURL=jdbc:h2:'db-name'
javax.jdo.option.ConnectionUserName=sa
javax.jdo.option.ConnectionPassword=
                
Informix

Informix is supported as an RDBMS datastore by JPOX

To specify Informix as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)

javax.jdo.option.ConnectionDriverName=com.informix.jdbc.IfxDriver
javax.jdo.option.ConnectionURL=jdbc:informix-sqli://[{ip|host}:port][/dbname]:INFORMIXSERVER=servername[;name=value[;name=value]...]
javax.jdo.option.ConnectionUserName=informix
javax.jdo.option.ConnectionPassword=password
                
javax.jdo.option.ConnectionDriverName=com.informix.jdbc.IfxDriver
javax.jdo.option.ConnectionURL=jdbc:informix-sqli://192.168.254.129:9088:informixserver=demo_on;database=buf_log_db
javax.jdo.option.ConnectionUserName=informix
javax.jdo.option.ConnectionPassword=password
                

Note that some database logging options in Informix do not allow changing autoCommit dinamically. You need to rebuild the database to support it. To rebuild the database refer to Informix documention, but as example, run $INFORMIXDIR\bin\dbaccess and execute the command "CREATE DATABASE mydb WITH BUFFERED LOG".

INDEXOF: Informix 11.x does not have a function to search a string in another string. JPOX defines a user defined function, JPOX_STRPOS, which is automatically created on startup. The SQL for the UDF function is:

create function JPOX_STRPOS(str char(40),search char(40),from smallint) returning smallint
    define i,pos,lenstr,lensearch smallint;
    let lensearch = length(search);
    let lenstr = length(str);

    if lenstr=0 or lensearch=0 then return 0; end if;

    let pos=-1;
    for i=1+from to lenstr
        if substr(str,i,lensearch)=search then
            let pos=i;
            exit for;
        end if;
    end for;
    return pos;
end function;                
                
McKoi

McKoi is supported as an RDBMS datastore by JPOX with the following proviso

  • McKoi doesn't provide full information to allow correct validation of tables/constraints.

To specify McKoi as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)

javax.jdo.option.ConnectionDriverName=com.mckoi.JDBCDriver
javax.jdo.option.ConnectionURL=jdbc:mckoi://'host':'port'/'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
                
PostgreSQL

To specify PostgreSQL as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)

javax.jdo.option.ConnectionDriverName=org.postgresql.Driver
javax.jdo.option.ConnectionURL=jdbc:postgresql://'host':'port'/'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
        		
PostgreSQL with PostGIS extension

To specify PostGIS as your datastore, you will need to decide first which geometry library you want to use and then set the connection url accordingly.

For the PostGIS JDBC geometries you will need something like the following specifying (replacing 'db-name' with name of your database etc)

javax.jdo.option.ConnectionDriverName=org.postgresql.Driver
javax.jdo.option.ConnectionURL=jdbc:postgresql://'host':'port'/'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
        		

For Oracle's JGeometry you will need something like the following specifying (replacing 'db-name' with name of your database etc)

javax.jdo.option.ConnectionDriverName=org.postgresql.Driver
javax.jdo.option.ConnectionURL=jdbc:postgres_jgeom://'host':'port'/'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
        		

For the JTS (Java Topology Suite) geometries you will need something like the following specifying (replacing 'db-name' with name of your database etc)

javax.jdo.option.ConnectionDriverName=org.postgresql.Driver
javax.jdo.option.ConnectionURL=jdbc:postgres_jts://'host':'port'/'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
        		
Apache Derby/Cloudscape

Apache Derby is supported as an RDBMS datastore by JPOX

To specify Apache Derby/Cloudscape as your datastore, you will need something like the following specifying (replacing 'db-name' with filename of your database etc)

javax.jdo.option.ConnectionDriverName=org.apache.derby.jdbc.EmbeddedDriver
javax.jdo.option.ConnectionURL=jdbc:derby:'db-name';create=true
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
                

Above settings are used together with the Apache Derby in embedded mode. The below settings are used in network mode, where the default port number is 1527.

javax.jdo.option.ConnectionDriverName=org.apache.derby.jdbc.ClientDriver
javax.jdo.option.ConnectionURL=jdbc:derby://'hostname':'portnumber'/'db-name';create=true
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
                

ASCII: Derby 10.1 does not have a function to convert a char into ascii code. JPOX needs such function to converts chars to int values when performing queries converting chars to ints. JPOX defines a user defined function, JPOX_ASCII, which is automatically created on startup. The SQL for the UDF function is:

DROP FUNCTION JPOX_ASCII;
CREATE FUNCTION JPOX_ASCII(C CHAR(1)) RETURNS INTEGER
EXTERNAL NAME 'org.jpox.store.rdbms.adapter.DerbySQLFunction.ascii'
CALLED ON NULL INPUT
LANGUAGE JAVA PARAMETER STYLE JAVA;

String.matches(pattern): When pattern argument is a column, JPOX defines a function that allows Derby 10.1 to perform the matches function. The SQL for the UDF function is:

DROP FUNCTION JPOX_MATCHES;
CREATE FUNCTION JPOX_MATCHES(TEXT VARCHAR(8000), PATTERN VARCHAR(8000)) RETURNS INTEGER
EXTERNAL NAME 'org.jpox.store.rdbms.adapter.DerbySQLFunction.matches'
CALLED ON NULL INPUT
LANGUAGE JAVA PARAMETER STYLE JAVA;
Firebird

Firebird is supported as an RDBMS datastore by JPOX with the proviso that

  • Auto-table creation is severely limited with Firebird. In Firebird, DDL statements are not auto-committed and are executed at the end of a transaction, after any DML statements. This makes "on the fly" table creation in the middle of a DML transaction not work. You must make sure that "autoStartMechanism" is NOT set to "SchemaTable" since this will use DML. You must also make sure that nobody else is connected to the database at the same time. Don't ask us why such limitations are in a RDBMS, but then it was you that chose to use it ;-)

To specify Firebird as your datastore, you will need something like the following specifying (replacing 'db-name' with filename of your database etc)

javax.jdo.option.ConnectionDriverName=org.firebirdsql.jdbc.FBDriver
javax.jdo.option.ConnectionURL=jdbc:firebirdsql://localhost/'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
                
SAPDB/MaxDB

To specify SAPDB/MaxDB as your datastore, you will need something like the following specifying (replacing 'db-name' with filename of your database etc)

javax.jdo.option.ConnectionDriverName=com.sap.dbtech.jdbc.DriverSapDB
javax.jdo.option.ConnectionURL=jdbc:sapdb://localhost/'db-name'
javax.jdo.option.ConnectionUserName='user-name'
javax.jdo.option.ConnectionPassword='password'
                
JDBC Driver parameters

If you need to pass additional parameters to the JDBC driver you can append these to the end of the javax.jdo.option.ConnectionURL. For example,

javax.jdo.option.ConnectionURL=jdbc:mysql://localhost?useUnicode=true&characterEncoding=UTF-8