Translate Connection String H2 (JDBC) to Mysql (JDBC)

Asked

Viewed 74 times

0

Personal talk,

I’m trying to run the OW2 Orchestra software, and it comes with a standard connection string belonging to H2 in the following format:

jdbc\:h2\:file\:/tmp/orchestra-db/orchestra_core.db

I need to translate it to a Mysql string (also JDBC), something like:

jdbc:mysql://localhost:3306/

With the same information from the original string.

The problem is that I don’t quite understand what the original string means! Can someone help me?

1 answer

0

'jdbc:H2:file:/tmp/orchestra-db/orchestra_core.db' follows the format:

jdbc:H2:file:[path]

Where:

  • jdbc: is a fixed string
  • H2: is the driver name used, in this case the driver for DB H2.
  • file: indicates to H2 that you are using a local DB
  • path, in this case '/tmp/orchestra-db/orchestra_core.db', indicates the DB path.

What must be confusing you are these bars (' ') that appear in your question. They are used to escape special characters, I believe.

Basically all this url says is:

Use a local DB that is in the file '/tmp/orchestra-db/orchestra_core.db'.

If you want to set up a similar mysql url just point to the localhost, as your example:

jdbc:mysql:/localhost:3306/

Note: You will have to choose which port mysql will run on.

  • Thank you for your reply! You don’t need to tell Mysql "where the local DB is" as specified in the H2 string?

  • @Mrguliarte I took a look at documentation, at first Mysql does not work with this format.

  • Got it! Strange, because I am using Hibernate and I continue with the error "could not get database Metadata" : / I think I will try the reverse solution and change pro H2 rs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.