Reputation: 85
I am using the HSQLDB in the testing envoirnment providing scripts to create tables then importing the test data to be inserted in the mocked database. In the production level we have Microsoft SQL server database. Still the HSQLDB giving me errors like:
java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: GETDATE
20:17:48,283 ERROR [Appeal] [proceessAppeal] [Error]
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
Upvotes: 0
Views: 1774
Reputation: 7283
Maybe you could write a custom function getDATE(), see this question
I use hsqldb in integration tests and oracle in production. Still some SQLs are not supported although hsqldb has a "SET DATABASE SQL SYNTAX ORA true" feature. Hence I avoid use unstandard sql functions as few as possible and just use HSQLDB for some insert/update/query tests(therefore some SQL scripts are not needed).
Upvotes: 0
Reputation: 24192
different databases support different built-in functions. hsqldb doesnt have a GETDATE() function like in mssql. it does have an equivalent function, CURRENT_TIMESTAMP(), but you cant just reuse the same SQL code between them.
if you want to do this, you will need to maintain 2 versions of your schema/queries, or (if its trivial enough, depending on what you use) just do a find-and-replace.
Upvotes: 1