• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

HSQLDB and TO_DATE

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing some JUnit test cases with HSQLDB.

I found that TO_DATE, TO_CHAR are not found in HSQLDB. Was wondering if anyone had a workaround for this. The team I am on uses HSQLDB as a test case database. But the actual Application will run against Oracle.

Any help will be appreciated.
TIA
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TO_DATE etc. are Oracle-specific SQL functions. They're not standard SQL so they don't exist in HSQLDB or other databases. To get around this, don't use those Oracle-specific functions, or use Oracle instead of HSQLDB for testing. If Oracle licenses are a problem, you could maybe use the free Oracle Express Edition for this purpose.
 
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Jesper says.

To make your application portable (you have this requirement, because it has to work on two database brands),
you have to use standard sql in your queries.

You should not need to_date.
If you have a select statement, you can retrieve date values by using ResultSet.getDate() and family.
If you have to use a date in the where clause, you should use PreparedStatement, and bind your date parameters.

Making an app database independent is not trivial. It's hard when you use frameworks that are specialised to do it, let alone without such a framework.
Databases behave differently (subtile - or sometimes not so subtile) even if you only use standard sql statements.
I don't know if it is a good idea to test your application with HSQLDB only, when production runs on Oracle.
I would certainly also include tests with an Oracle database.
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic