0

I am using HSQL in-memory DB for test cases,which will execute

TRUNCATE TABLE TABLE_NAME IGNORE DELETE TRIGGERS DROP STORAGE IMMEDIATE

Below error encountering when running the test case.

StatementCallback; bad SQL grammar [TRUNCATE TABLE TABLE_NAME]; 
nested exception is java.sql.SQLException: Unexpected token: TRUNCATE in statement [TRUNCATE]
5
  • TRUNCATE should work in HSQLDB, but everything after the table name is invalid in HSQLDB as documented in the manual: hsqldb.org/doc/2.0/guide/…
    – user330315
    Nov 20, 2014 at 9:04
  • Why did you add the db2 tag if you are using HSQLDB?
    – user330315
    Nov 20, 2014 at 15:19
  • Need to write JUnit for spring DAO class,which is talking with DB2 and query is"TRUNCATE TABLE TABLE_NAME IGNORE DELETE TRIGGERS DROP STORAGE IMMEDIATE".So I need to write a JUnit class without modifying source query. Of course HSQLDB supporting TRUNCATE statement,but needs to use as source query is. Does HSQLDB has DB2 template?,if not what is the solution please suggest me
    – Raj
    Nov 23, 2014 at 11:04
  • In my personal opinion testing against a different DBMS than you use in production doesn't really make sense. There are obvious syntactical difference that require you to change your code (which makes the test invalid as you are testing different code) and there are behavioural difference (sometimes very subtle ones) that might result in code passing the tests but fail in production.
    – user330315
    Nov 23, 2014 at 11:07
  • Could you please share how to setup stand-alone/server(JBOSS or any other open-source) environment to test the above scenario
    – Raj
    Nov 23, 2014 at 17:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.