Skip to content

Parse db.instance from JDBC URL #1841

@SylvainJuge

Description

@SylvainJuge

Is your feature request related to a problem?

This is a follow-up issue on #1800 (use either Connection#getCatalog or Connection#getSchema for db.instance field, which is covered by pr #1820 .

In some cases mentioned in #1800 (comment), we can't use getCatalog and proper JDBC URL parsing seems the right option to populate the db.instance field.

Describe the solution you'd like

  • try to parse the db.instance value from JDBC URL.
  • for Oracle, rely in the SERVICE_NAME attribute in JDBC URL if provided, with fallback to SID or INSTANCE_NAME
  • when it can't be parsed, then we should fallback to using Connection#getConnection at the time when the connection is created.

While Connection#setCatalog (or Connection#setSchema) could be called at runtime to change the current catalog on the connection, this feature is assumed to be quite rarely used, and would further complicate things. Also, keeping a stable value over time that would be consistent with application configuration (here the JDBC URL) seems a reasonable option.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions