RDBMS | Driver | Tester |
---|---|---|
Apache Derby | org.apache.derby.jdbc.EmbeddedDriver | Thomas Fox |
Hsqldb | org.hsql.jdbcDriver | Thomas Fox |
MySQL | org.gjt.mm.mysql.Driver | Scott Eade |
Postgres | org.postgresql.Driver | Scott Eade |
Oracle | oracle.jdbc.driver.OracleDriver | Thomas Fox |
MS SQL | net.sourceforge.jtds.jdbc.Driver | Greg Monroe |
If your RDBMS is not listed here, please read the document about writing DB Adapters.
Torque 4 was tested against MySQL 5.5. Subselects are known not to work for MySQL < 4.1. There are no other known issues for old MySQL versions.
The MySQL templates can handle create options for tables. For example, the desired create-sql output is
CREATE TABLE book ( ... ) COLLATE=latin1_german2_ci ENGINE=InnoDB;
For this, specify the desired options in the option elements of the table to create:
<table name="book" description="Book table"> <option key="COLLATE" value="latin1_german2_ci"/> <option key="ENGINE" value="InnoDB"/> ... </table>
Torque recognizes the following keys to be separated with an equals character("=") between key and value:
Torque recognizes the following keys to be separated with a space character(" ") between key and value:
All other keys are ignored.
Torque 4 was tested against PostgreSQL 9.1. The CASCADE option for the drop table commands in the generated SQL will only work for PostgreSQL 7.3 and later. Columns declared as BLOB can not be set to null by Torque, as torque maps them to BYTEA but treats them as Types.BLOB internally, which is not accepted by Postgresql. Use one of the other *BINARY types instead, they are all mapped to the postgresql datatype BYTEA. There are no other known issues for old PostgreSQL versions.
Torque 4 was tested against Oracle 11g. There are no known issues for Oracle 9i and later. The following issues exist for older versions of Oracle:
The data type TIMESTAMP is not supported up to and including Oracle 8.1.7. Use the types DATE or TIME instead of TIMESTAMP.
TODO check for Torque 4 The data type TIME only has day accuracy for Oracle. This is due to the fact that oracle does not support a SQL type TIME. If you are using Oracle 9i and later, you can use the type TIMESTAMP instead which gives you millisecond accuracy.
Oracle does not distinguish between empty strings and null strings.
If an empty string is inserted into a table, it will be treated as null.
If you want to re-read this column by selecting records which contain
an empty string, oracle will return no columns. The only way to select
the column is to query for records which contain null in that column.
This behaviour is different in most other databases. So if you
want to write code which works for other databases and oracle, you need
to consider both cases - the column might be null and it might contain
an empty string. For example:
Criterion c1 = new Criterion(COLUMN, "", Criteria.EQUAL); Criterion c2 = new Criterion(COLUMN, null, Criteria.ISNULL); criteria.and(c1.or(c2));
Torque 4 was tested against MSSQL 2012. There are no known issues for MSSQL versions >= MSSQL 2000. See the jira issue TORQUE-46 for the issues with MSSQL 7.
It helps to name the database the same name as your project. If the name is not the same, you will need to manually change the database name in your properties files. After the database is created, you will need to create a new user, or give an existing user permissions to the new database. Create the new user with SQL Server Authentication, and assign the users default database to the newly created database. Make sure the database user has the db_owner role. Please refer to SQL Server documentation for further details.
There is an excellent open source driver for MS SQL called jTDS. This driver is being used in production mode with Torque and many other JDBC applications. This driver is used for testing Torque with MSSQL, other drivers should work the same, but your milage may vary.