javaoracle-databasejdbcnetwork-programming

is there a way to print the database server IP to which jdbc connection is established?


I want to print the server IP address in the connection. I'm connection to Oracle RAC service and DBA is complaining each time the connection is being made to only Instance1.

Is there a way to print the IP address of the server to which connection is established?

e.g.
Connection conn = connection = DriverManager.getConnection(
                                "jdbc:oracle:thin:@oracleScanIP:1521/SERVICENAME", "USERNAME",
                                "PWD");
    Now I want IP address to which connection is established.
    conn.xyz? may be

Solution

  • java.sql.Connection has a getMetaData() function which returns DatabaseMetaData object. Do a getURL() on it, you must get the connection details out of it.

    Something like this

    conn.getMetaData().getURL()