Tuesday, June 26, 2012

Enable Oracle-Featues in HSQLDB

If you are using HSQLDB for rapid development there is an easy way to enable Oracle-specific features like:
  • DUAL 
  • ROWNUM 
  • NEXTVAL 
  • CURRVAL 
  • ... 
 Just set the Property sql.syntax_ora to true or false (if you would like to disable)
SET DATABASE SQL SYNTAX ORA { TRUE | FALSE }

Without this property you will get a:
java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: DUAL
when executing for example:

SELECT SYSDATE FROM DUAL;

Defining this property in your persistence.xml your javax.persistence.jdbc.url could look like this:

There are of course properties to enable some other vendor-specific database featues for:
  • DB2: sql.syntax_db2 
  • MySQL: sql.syntax_mys
  • MS SQL: sql.syntax_mss 
  • PostgreSQL: sql.syntax_pgs

No comments:

Post a Comment