h2database / h2database/h2database

JDBC connection.getMetaData().getURL() must return url including parameters

Open
#3,943 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
4.6k
Forks
1.3k
Avg merge
1d 2h
Merged PRs (30d)
9

Description

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 of H2 Connection

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

And this is output of PostgreSQL:

URL 1:jdbc:postgresql://localhost:5432/test?connect_timeout=10
URL 2:jdbc:postgresql://localhost:5432/test?connect_timeout=10

We see that PostgreSQL returns URL including parameters while H2 not.

So I suggest to add possibility to get parameters from Connection in H2. For example, I have connection somewhere inside program and I want to check what H2 Mode is currently used.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing H2's JDBC connection metadata implementation and how the connection URL is stored or reconstructed. Reproduce the example with the H2 URL parameters, then verify that Connection.getMetaData().getURL() preserves them and that the reported URL still matches the original connection settings.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.