H2 to access non-h2 databases

The H2 console ( http: // localhost: 8082 / login.jsp ) has the ability to view the details of any database where we need to copy the jdbc driver if we talk to tp with the mysql server or other database servers. Copying the jdbc driver file (mysql-connector-java-5.0.8-bin.jar) from the bin directory did not seem to help

Note. My H2 server is running as a service

+3
source share
2 answers

To use other databases (such as MySQL), the JDBC driver location of these databases must be added to the H2DRIVERS or CLASSPATH environment variables before installing the service. You can install multiple drivers; each entry must be separated by a; (Windows) or: (other operating systems). Spaces in path names are supported. Settings should not be specified.

+2
source

I just put the driver on classpathwhen the server starts:

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 that you can add JARto one of java.ext.dirs. You can see what is available on your platform:

System.out.println(System.getProperty("java.ext.dirs"));
+2
source

Source: https://habr.com/ru/post/1753977/


All Articles