Fell
Fell

Reputation: 765

how to get oracle port no from sql query

Is it possible to get the oracle server port no from a sql query?

Thanks,
Fell

Upvotes: 0

Views: 13959

Answers (2)

Nick Holt
Nick Holt

Reputation: 34311

No, but in order to run a query you're going to need a connection to the DB so I suspect you can get the port using a call to java.sql.DatabaseMetaData.getURL(). Not sure exactly what the Oracle drivers return but something like this should do the trick:

String url = connection.getMetadata().getURL();
String port = url.substring(url.indexOf(":"), url.indexof("/", url.indexOf(":")) - 1);

Upvotes: 0

davek
davek

Reputation: 22915

It doesn't seem to be directly possible: see the discussion here on askTom

Upvotes: 3

Related Questions