Sam
Sam

Reputation: 8693

H2 console access for databases other than h2

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

Upvotes: 5

Views: 3358

Answers (2)

Thomas Mueller
Thomas Mueller

Reputation: 50087

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.

Upvotes: 3

trashgod
trashgod

Reputation: 205765

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"));

Upvotes: 2

Related Questions