JDBC retrieve the server name/ip from a java.sql.connection

Discussion in 'Java' started by dnasmars, Sep 28, 2005.

  1. dnasmars

    dnasmars Guest

    Hi all,

    is it possible to retrieve the server name or ip
    from a Connection or a Statement
    from the package java.sql.
    thank you in advance
    dnasmars, Sep 28, 2005
    #1
    1. Advertising

  2. dnasmars

    Roedy Green Guest

    On Wed, 28 Sep 2005 16:00:10 +0200, dnasmars <> wrote
    or quoted :

    >is it possible to retrieve the server name or ip
    >from a Connection or a Statement
    >from the package java.sql.
    >thank you in advance


    Try Driver.getPropertyInfo and dig around to see what is in there.
    I gather you have already pawed through Connection.getMetaData

    Perhaps you can get an URL and from that a name and from that an IP.

    See http://mindprod.com/jgloss/uri.html
    http://mindprod.com/jgloss/ip.html

    Another approach is to save the url when you are constructing your
    connect string rather than trying to extract it later.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
    Roedy Green, Sep 28, 2005
    #2
    1. Advertising

  3. dnasmars

    dnasmars Guest

    Roedy Green wrote:
    > On Wed, 28 Sep 2005 16:00:10 +0200, dnasmars <> wrote
    > or quoted :
    >
    >
    >>is it possible to retrieve the server name or ip

    >
    >>from a Connection or a Statement
    >>from the package java.sql.

    >
    >>thank you in advance

    >
    >
    > Try Driver.getPropertyInfo and dig around to see what is in there.
    > I gather you have already pawed through Connection.getMetaData
    >
    > Perhaps you can get an URL and from that a name and from that an IP.
    >
    > See http://mindprod.com/jgloss/uri.html
    > http://mindprod.com/jgloss/ip.html
    >
    > Another approach is to save the url when you are constructing your
    > connect string rather than trying to extract it later.

    thank you for the information I'll try
    and will let you all know :)
    dnasmars, Sep 29, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page