3

I am running an H2 in memory database with following connection url:

"jdbc:h2:mem:my_database;DB_CLOSE_DELAY=-1;MODE=MySQL"

H2 allows to start servers to be able to establish alternative connections to the in memory database:

                sysLog.info("Creating web server.");
                String[] webServerSettings = new String[]{"-webPort","8085","-webAllowOthers"};
                webServer = Server.createWebServer(webServerSettings);
                webServer.start();

                sysLog.info("Creating tcp server.");
                String[] tcpServerSettings = new String[]{"-tcpPort","9095","-tcpAllowOthers"};
                tcpServer = Server.createTcpServer(tcpServerSettings);
                tcpServer.start();

http://www.h2database.com/javadoc/org/h2/tools/Server.html

After creating a server I am able to show a web console and browse the database content. However, I would prefer to use MySQL Workbench for that purpose and I did not yet succeed to connect MySQL Workbench to such an H2 server.

If I use the connection settings localhost:8085 or localhost:9095 in MySQL Workbench following error occurs:

Lost connection to MySQL server at 'waiting for initial communication packet', system error:10060

My Questions: Is it possible to use MySQL Workbench (or Navicat for MySQL) to connecto to an H2 database at all? If yes, what are the right settings?

(Alternatives to MySQL Workbench are given here: Frontend tool to manage H2 database)

Community
  • 1
  • 1
Stefan
  • 10,010
  • 7
  • 61
  • 117
  • Haven't tried myself, but if it is accessible via normal TCP/IP or a socket/pipe then yes, why not? Just specify your localhost address and the port in the settings to connect to it. – Mike Lischke Feb 25 '15 at 08:50
  • Simply specifying the host and port gives the error message that is already shown above. In the MySQL Workbench it is not possible to enter a complete jdbc url (as it would work for example with DBeaver). But maybe there is some kind of work around to redirect the commands that MySQL Workbench sends to host:port ... to the correct jdbc url for H2? I am not so familiar with tunnels, pipes, ... (The H2 dialect is a little different from MySQL and that might cause connection issues.) – Stefan Feb 25 '15 at 12:49
  • @Stefan Yes, I thought MySQLWorkbench is a little foolish... – Tommy.Tang Jan 20 '20 at 09:05

1 Answers1

2

No, H2 implements PostgreSQL protocols, as stated at the ODBC Driver section of the documentation.

Usagi Miyamoto
  • 6,196
  • 1
  • 19
  • 33