Search code examples
javajdbch2

How to get URL parameters from H2 Connection?


I need to get URL parameters from H2 connection.

This is my code:

System.out.println("URL 1:" + url);
var connection = DriverManager.getConnection(url, user, password);
System.out.println("URL 2:" + connection.getMetaData().getURL());

And this is output

URL 1:jdbc:h2:tcp://localhost/test;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE;DEFAULT_NULL_ORDERING=HIGH;TRACE_LEVEL_FILE=0
URL 2:jdbc:h2:tcp://localhost/test

As we see connection.getMetaData().getURL() returns no parameters. Besides getURL() returns String. However, I need to get URL parameters from Connection.

Could anyone say how to do it?


Solution

  • Now H2 doesn't provide parameters in url returned from java.sql.DatabaseMetaData.getURL() method. On the base of this question an issue was opened. So, it is possible to check current situation there.