DataNucleus supports persisting objects to RDBMS datastores (using the datanucleus-rdbms plugin). It supports the vast majority of RDBMS products available today. DataNucleus communicates with the RDBMS datastore using JDBC. RDBMS systems accept varying standards of SQL and so DataNucleus will support particular RDBMS/JDBC combinations only, though clearly we try to support as many as possible. There are tutorials available for use of DataNucleus with RDBMS for JDO and for JPA By default when you create a PersistenceManagerFactory (PMF) to connect to a particular datastore DataNucleus 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 DataNucleus 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 DataNucleus has been tested with
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.
To specify DB2 as your datastore, you will need something like the following specifying (where "mydb1" is the name of the database) datanucleus.ConnectionDriverName=com.ibm.db2.jcc.DB2Driver datanucleus.ConnectionURL=jdbc:db2://localhost:50002/mydb1 datanucleus.ConnectionUserName='username' (e.g db2inst1) datanucleus.ConnectionPassword='password' With DB2 Express-C v9.7 you need to have db2jcc.jar and db2jcc_license_cu.jar in the CLASSPATH.
MySQL is supported as an RDBMS datastore by DataNucleus with the following provisos
To specify MySQL as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)
datanucleus.ConnectionDriverName=com.mysql.jdbc.Driver
datanucleus.ConnectionURL=jdbc:mysql://'host':'port'/'db-name'
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
MS SQL Server is supported as an RDBMS datastore by DataNucleus with the following proviso
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)
datanucleus.ConnectionDriverName=com.microsoft.sqlserver.jdbc.SQLServerDriver
datanucleus.ConnectionURL=jdbc:sqlserver://'host':'port';DatabaseName='db-name'
;SelectMethod=cursor
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
Microsoft SqlServer 2000 JDBC Driver
datanucleus.ConnectionDriverName=com.microsoft.jdbc.sqlserver.SQLServerDriver
datanucleus.ConnectionURL=jdbc:microsoft:sqlserver://'host':'port';DatabaseName='db-name'
;SelectMethod=cursor
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
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.
datanucleus.ConnectionDriverName=oracle.jdbc.driver.OracleDriver
datanucleus.ConnectionURL=jdbc:oracle:thin:@'host':'port':'db-name'
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
To specify Sybase as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)
datanucleus.ConnectionDriverName=com.sybase.jdbc2.jdbc.SybDriver
datanucleus.ConnectionURL=jdbc:sybase:Tds:'host':'port'/'db-name'
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
HSQLDB is supported as an RDBMS datastore by DataNucleus with the following proviso
To specify HSQL (1.x) as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)
datanucleus.ConnectionDriverName=org.hsqldb.jdbcDriver
datanucleus.ConnectionURL=jdbc:hsqldb:hsql://'host':'port'/'db-name'
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
Note that in HSQLDB v2.x the driver changes to org.hsqldb.jdbc.JDBCDriver
H2 is supported as an RDBMS datastore by DataNucleus To specify H2 as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)
datanucleus.ConnectionDriverName=org.h2.Driver
datanucleus.ConnectionURL=jdbc:h2:'db-name'
datanucleus.ConnectionUserName=sa
datanucleus.ConnectionPassword=
Informix is supported as an RDBMS datastore by DataNucleus To specify Informix as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)
datanucleus.ConnectionDriverName=com.informix.jdbc.IfxDriver
datanucleus.ConnectionURL=jdbc:informix-sqli://[{ip|host}:port][/dbname]:
INFORMIXSERVER=servername[;name=value[;name=value]...]
datanucleus.ConnectionUserName=informix
datanucleus.ConnectionPassword=password
datanucleus.ConnectionDriverName=com.informix.jdbc.IfxDriver
datanucleus.ConnectionURL=jdbc:informix-sqli://192.168.254.129:9088:
informixserver=demo_on;database=buf_log_db
datanucleus.ConnectionUserName=informix
datanucleus.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. DataNucleus defines a user defined function, DATANUCLEUS_STRPOS, which is automatically created on startup. The SQL for the UDF function is:
create function DATANUCLEUS_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 is supported as an RDBMS datastore by DataNucleus with the following proviso
To specify McKoi as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)
datanucleus.ConnectionDriverName=com.mckoi.JDBCDriver
datanucleus.ConnectionURL=jdbc:mckoi://'host':'port'/'db-name'
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
To specify PostgreSQL as your datastore, you will need something like the following specifying (replacing 'db-name' with name of your database etc)
datanucleus.ConnectionDriverName=org.postgresql.Driver
datanucleus.ConnectionURL=jdbc:postgresql://'host':'port'/'db-name'
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
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)
datanucleus.ConnectionDriverName=org.postgresql.Driver
datanucleus.ConnectionURL=jdbc:postgresql://'host':'port'/'db-name'
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
For Oracle's JGeometry you will need something like the following specifying (replacing 'db-name' with name of your database etc)
datanucleus.ConnectionDriverName=org.postgresql.Driver
datanucleus.ConnectionURL=jdbc:postgres_jgeom://'host':'port'/'db-name'
datanucleus.ConnectionUserName='user-name'
datanucleus.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)
datanucleus.ConnectionDriverName=org.postgresql.Driver
datanucleus.ConnectionURL=jdbc:postgres_jts://'host':'port'/'db-name'
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
Apache Derby is supported as an RDBMS datastore by DataNucleus 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)
datanucleus.ConnectionDriverName=org.apache.derby.jdbc.EmbeddedDriver
datanucleus.ConnectionURL=jdbc:derby:'db-name';create=true
datanucleus.ConnectionUserName='user-name'
datanucleus.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.
datanucleus.ConnectionDriverName=org.apache.derby.jdbc.ClientDriver
datanucleus.ConnectionURL=jdbc:derby://'hostname':'portnumber'/'db-name';create=true
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
ASCII : Derby 10.1 does not have a function to convert a char into ascii code. DataNucleus needs such function to converts chars to int values when performing queries converting chars to ints. DataNucleus defines a user defined function, DataNucleus_ASCII, which is automatically created on startup. The SQL for the UDF function is: DROP FUNCTION NUCLEUS_ASCII; CREATE FUNCTION NUCLEUS_ASCII(C CHAR(1)) RETURNS INTEGER EXTERNAL NAME 'org.datanucleus.store.rdbms.adapter.DerbySQLFunction.ascii' CALLED ON NULL INPUT LANGUAGE JAVA PARAMETER STYLE JAVA; String.matches(pattern) : When pattern argument is a column, DataNucleus defines a function that allows Derby 10.1 to perform the matches function. The SQL for the UDF function is: DROP FUNCTION NUCLEUS_MATCHES; CREATE FUNCTION NUCLEUS_MATCHES(TEXT VARCHAR(8000), PATTERN VARCHAR(8000)) RETURNS INTEGER EXTERNAL NAME 'org.datanucleus.store.rdbms.adapter.DerbySQLFunction.matches' CALLED ON NULL INPUT LANGUAGE JAVA PARAMETER STYLE JAVA;
Firebird is supported as an RDBMS datastore by DataNucleus with the proviso that
To specify Firebird as your datastore, you will need something like the following specifying (replacing 'db-name' with filename of your database etc)
datanucleus.ConnectionDriverName=org.firebirdsql.jdbc.FBDriver
datanucleus.ConnectionURL=jdbc:firebirdsql://localhost/'db-name'
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
To specify SAPDB/MaxDB as your datastore, you will need something like the following specifying (replacing 'db-name' with filename of your database etc)
datanucleus.ConnectionDriverName=com.sap.dbtech.jdbc.DriverSapDB
datanucleus.ConnectionURL=jdbc:sapdb://localhost/'db-name'
datanucleus.ConnectionUserName='user-name'
datanucleus.ConnectionPassword='password'
SQLite is supported as an RDBMS datastore by DataNucleus with the proviso that
To specify SQLite as your datastore, you will need something like the following specifying (replacing 'db-name' with filename of your database etc)
datanucleus.ConnectionDriverName=org.sqlite.JDBC
datanucleus.ConnectionURL=jdbc:sqlite:'db-name'
datanucleus.ConnectionUserName=
datanucleus.ConnectionPassword=
If you need to pass additional parameters to the JDBC driver you can append these to the end of the datanucleus.ConnectionURL . For example, datanucleus.ConnectionURL=jdbc:mysql://localhost?useUnicode=true&characterEncoding=UTF-8 |