Starting/stopping H2 with ant?

444 views
Skip to first unread message

Giorgio Vespucci

unread,
Feb 16, 2010, 8:47:33 AM2/16/10
to H2 Database
Hi all

I'm installed H2 on a Windows PC.
I would start H2 from ant so that it can be automatically started/
stopped during a test suite execution.
How can I do this with ant?
Have I to call .bat in ./service directory or what?
I can't find any H2-ant-tasks library.

Thanks
--
Giorgio

Thomas Mueller

unread,
Feb 18, 2010, 1:25:25 PM2/18/10
to h2-da...@googlegroups.com
Hi,

I'm sure it's possible to start/stop H2 within an Ant script. And I'm
sure it would be quite easy. However, there are easier ways. For
testing, usually I would try to use the embedded mode because it is
faster than the server mode. Sometimes you could even use the
in-memory mode. If you want to be able to access the database while
the test runs you could use the auto-server mode:
http://www.h2database.com/html/features.html#auto_mixed_mode

Regards,
Thomas

Giorgio Vespucci

unread,
Feb 19, 2010, 3:49:29 AM2/19/10
to h2-da...@googlegroups.com
2010/2/18 Thomas Mueller <thomas.to...@gmail.com>:
Hi Thomas

I have exactly intention to use in-memory mode.
This auto mixed mode is very very interesting!

I'm substituing Oracle XE with H2 in-memory in our project, to
enhance the speed of suite execution.

Most of problems I'm facing to are in SQL grammar.
We have a lot of Oracle TO_DATE() for test data and actually I'm
looking for a free SQL translator Oracle-to-H2.

Someone in the list had ever used such a translator?

Thanks
--
Giorgio Vespucci
giorgio [dot] vespucci [at] gmail [dot] com
Skype, Twitter, Slideshare: gvespucci
Linux User #471792
http://xpermanwalking.blogspot.com

Giorgio Vespucci

unread,
Feb 19, 2010, 3:55:21 AM2/19/10
to h2-da...@googlegroups.com
2010/2/19 Giorgio Vespucci <giorgio....@gmail.com>:

> Hi Thomas
>
> I have exactly intention to use in-memory mode.
> This auto mixed mode is very very interesting!
Thomas
I did'n undesrtand is H2 windows service must be runnig or not, to use
the AUTO_SERVER=TRUE

I tried with service down, but H2 says org.h2.jdbc.JdbcSQLException:
Connection is broken: "session closed" [90067-128]
mumble, mumble...

Thomas Mueller

unread,
Feb 21, 2010, 12:00:48 PM2/21/10
to h2-da...@googlegroups.com
Hi,

> We have a lot of Oracle TO_DATE()

You could create a Java function. Example (not optimized):

create alias TO_DATE as $$
java.util.Date toDate(String s) throws Exception {
return new java.text.SimpleDateFormat("yyyy.MM.dd").parse(s);
}
$$;
call TO_DATE('1990.02.03');

See also http://www.h2database.com/html/grammar.html#create_alias

> I did'n undesrtand is H2 windows service must be runnig or not

It doesn't.

> "session closed" [90067-128]

What is your database URL, and what is the exact exception message and
stack trace?

Regards,
Thomas

Sam Blume

unread,
Feb 10, 2016, 7:13:44 AM2/10/16
to H2 Database, giorgio....@gmail.com
Hi 

FYI; I've contributed the TO_DATE (and TO_TIMESTAMP) code to H2 and it should be in Version 1.4.191 (It's not mentioned in the change log :-( ). 
Note: If you have programed an alias with that name, you need to delete that alias first or H2 will complain of having a name clash.

Cheers Sam

Reply all
Reply to author
Forward
0 new messages