tags:

views:

48

answers:

2

H2 console (http://localhost:8082/login.jsp) has the option to look at details of any database, where should we copy the jdbc driver if we have tp talk to the mysql or other database servers. Copying the jdbc driver file (mysql-connector-java-5.0.8-bin.jar) under bin directory didn't seem to help

Note: My H2 server is running as a service

+1  A: 

I just put the driver(s) on the classpath when I start the server:

classpath=.:/opt/h2/bin/h2.jar:/opt/derby/lib/derby.jar:...
server=org.h2.tools.Server
java -cp ${classpath} ${server} -tcp -web ... &

Alternatively, this is one of the rare times you might add a JAR to one of the java.ext.dirs. You can see what's available on your platform:

System.out.println(System.getProperty("java.ext.dirs"));
trashgod
used the ext folder for the time being
Samuel
@Samuel: While convenient, it's a problem if you forget it's there (he said ruefully:-). You might check if your service wrapper can accommodate.
trashgod
yes, I did have the same concern. Did look at the service wrapper scripts, but I wasn't sure where | how to add these external jars
Samuel
+2  A: 

To use other databases (for example MySQL), the location of the JDBC drivers of those databases need to be added to the environment variables H2DRIVERS or CLASSPATH before installing the service. Multiple drivers can be set; each entry needs to be separated with a ; (Windows) or : (other operating systems). Spaces in the path names are supported. The settings must not be quoted.

Thomas Mueller
Using the H2DRIVERS variable might be the right option to use (http://www.h2database.com/html/tutorial.html#tutorial_starting_h2_console), will give this a try soon
Samuel