sproketboy
sproketboy

Reputation: 9472

how to get get the JDBC connection url string

I don't know why I can't find this. My library takes a jdbc connection object and I need to support some different meta-data for different connections (which may be to different databases) so I figure I could use the connection URL string as the key for my map but I can't find it.

Is there any way to get the connection URL string from a connection object?

Upvotes: 3

Views: 3730

Answers (1)

Simon C
Simon C

Reputation: 2017

Connection.getMetaData().getURL() or one of the other methods such as DatabaseMetadata.getDriverName() will give you information about the database connection.

Upvotes: 5

Related Questions