lunes, 10 de septiembre de 2012

Accesing a H2 server database with PostgreSQL driver via ODBC

In order to setup a h2 instance we must start h2 daemon with the following syntax:
java -jar h2-1.3.163.jar -tcp -pg  -baseDir /temp/db2
This command line means :
start h2 in server mode, allowing connections only from localhost setting root database to /temp/db2.

Other interesting options are:
-tcpPort 9101
-tcpAllowOthers
-pgAllowOthers 

In order to create the database you must connect with admin user (SA and password recommended) for the very first time. For that you only need a jdbc connection.

If the database does not have a password for the SA user, you must set it with the folling command:
ALTER USER SA SET PASSWORD 'sa'


Then you can connect with a PostgreSQL client to the h2 database.