Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

How to tell name of server/database you're connected to?

5 posts in JDBC Connect (product renamed to JConnect) Last posting was on 1997-07-30 17:58:25.0Z
Don Blair Posted on 1997-07-16 13:51:39.0Z
Message-ID: <33CCD1EB.3067@sybase.com>
Date: Wed, 16 Jul 1997 09:51:39 -0400
From: Don Blair <dblair@sybase.com>
Reply-To: dblair@sybase.com
Organization: Powersoft
X-Mailer: Mozilla 3.0 (Win95; I)
MIME-Version: 1.0
CC: dblair
Subject: How to tell name of server/database you're connected to?
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 11
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:538
Article PK: 252290

Can jConnect tell you the name of the server & database
you're connected to?

For instance, suppose the user connects to this URL:

jdbc:sybase:Tds:donspc:4444

I'd like to be able to find the name of the server
& database that I reached.

When jConnect supports JNDI, then I can pull the
server name out of the URL. However, I will still
need help on the database name.

Don


David Wolf Posted on 1997-07-16 18:34:03.0Z
Message-ID: <33CD141A.4AEDA127@sybase.com>
Date: Wed, 16 Jul 1997 11:34:03 -0700
From: David Wolf <dwolf@sybase.com>
Reply-To: dwolf@sybase.com
Organization: Sybase Professional Services
X-Mailer: Mozilla 4.0 [en] (Win95; U)
MIME-Version: 1.0
Subject: Re: How to tell name of server/database you're connected to?
X-Priority: 3 (Normal)
References: <33CCD1EB.3067@sybase.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 17
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:537
Article PK: 252288

Don,

Why not create a statement object or a PreparedStatement object and
place the 'select db_name()' SQL function into it. The use it at will

Dave Wolf
Sybase Professional Services

Don Blair wrote:

> Can jConnect tell you the name of the server & database
> you're connected to?
>
> For instance, suppose the user connects to this URL:
>
> jdbc:sybase:Tds:donspc:4444
>
> I'd like to be able to find the name of the server
> & database that I reached.
>
> When jConnect supports JNDI, then I can pull the
> server name out of the URL. However, I will still
> need help on the database name.
>
> Don


Don Blair Posted on 1997-07-16 18:04:54.0Z
Message-ID: <33CD0D46.59EB@sybase.com>
Date: Wed, 16 Jul 1997 14:04:54 -0400
From: Don Blair <dblair@sybase.com>
Reply-To: dblair@sybase.com
Organization: Powersoft
X-Mailer: Mozilla 3.0 (Win95; I)
MIME-Version: 1.0
CC: dblair
Subject: Re: How to tell name of server/database you're connected to?
References: <33CCD1EB.3067@sybase.com> <33CD141A.4AEDA127@sybase.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 22
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:532
Article PK: 252284

Thanks.

I've discovered that you can find the server name
with this query:

SELECT @@servername

Don
--------------------------------

David Wolf wrote:
>
> Don,
>
> Why not create a statement object or a PreparedStatement object and
> place the 'select db_name()' SQL function into it. The use it at will
>
> Dave Wolf
> Sybase Professional Services
>
> Don Blair wrote:
>
> > Can jConnect tell you the name of the server & database
> > you're connected to?
> >
> > For instance, suppose the user connects to this URL:
> >
> > jdbc:sybase:Tds:donspc:4444
> >
> > I'd like to be able to find the name of the server
> > & database that I reached.
> >
> > When jConnect supports JNDI, then I can pull the
> > server name out of the URL. However, I will still
> > need help on the database name.
> >
> > Don


David Wolf Posted on 1997-07-17 06:37:15.0Z
Message-ID: <33CDBD9A.93DAC63F@sybase.com>
Date: Wed, 16 Jul 1997 23:37:15 -0700
From: David Wolf <dwolf@sybase.com>
Reply-To: dwolf@sybase.com
Organization: Sybase Professional Services
X-Mailer: Mozilla 4.0 [en] (Win95; U)
MIME-Version: 1.0
Subject: Re: How to tell name of server/database you're connected to?
X-Priority: 3 (Normal)
References: <33CCD1EB.3067@sybase.com> <33CD141A.4AEDA127@sybase.com> <33CD0D46.59EB@sybase.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 36
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:527
Article PK: 252279

heh-

Well Don, I could look at what you asked, and could have given you the
code for servername, rather than database name like I did. One note
about @@servername global variable is that it is only set if the DBA was
a good little boy/girl and added the server name to master..sysservers,
which they sometimes dont, so be sure to have logic in there in case
SELECT @@servername returns a SQL NULL.

Dave Wolf
Sybase Professional Services

Don Blair wrote:

> Thanks.
>
> I've discovered that you can find the server name
> with this query:
>
> SELECT @@servername
>
> Don
> --------------------------------
> David Wolf wrote:
> >
> > Don,
> >
> > Why not create a statement object or a PreparedStatement object and
> > place the 'select db_name()' SQL function into it. The use it at
> will
> >
> > Dave Wolf
> > Sybase Professional Services
> >
> > Don Blair wrote:
> >
> > > Can jConnect tell you the name of the server & database
> > > you're connected to?
> > >
> > > For instance, suppose the user connects to this URL:
> > >
> > > jdbc:sybase:Tds:donspc:4444
> > >
> > > I'd like to be able to find the name of the server
> > > & database that I reached.
> > >
> > > When jConnect supports JNDI, then I can pull the
> > > server name out of the URL. However, I will still
> > > need help on the database name.
> > >
> > > Don


David Clegg Posted on 1997-07-30 17:58:25.0Z
Message-ID: <33DF80C1.531E99D5@sybase.com>
Date: Wed, 30 Jul 1997 10:58:25 -0700
From: David Clegg <davec@sybase.com>
X-Mailer: Mozilla 3.01 (X11; I; Linux 1.2.13 i586)
MIME-Version: 1.0
To: dwolf@sybase.com
CC: dblair@sybase.com
Subject: Re: How to tell name of server/database you're connected to?
References: <33CCD1EB.3067@sybase.com> <33CD141A.4AEDA127@sybase.com> <33CD0D46.59EB@sybase.com> <33CDBD9A.93DAC63F@sybase.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 51
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:448
Article PK: 252199

Connection.getMetaData().getCatalog() will return the database
name in a JDBC standard fashion (assuming that you do have the
jConnect MetaData support loaded on the server).

There is no similar thing for getting the server name, and as Dave
indicated, the @@servername is arbitrary -- certainly not a
unique identifier that you would hope to use with JNDI. We'll be
down talking with JavaSoft on Friday about JNDI, hoping to clarify
standard usage scenarios w/respect to JDBC.

dave

>
> heh-
>
> Well Don, I could look at what you asked, and could have given you the
> code for servername, rather than database name like I did. One note
> about @@servername global variable is that it is only set if the DBA was
> a good little boy/girl and added the server name to master..sysservers,
> which they sometimes dont, so be sure to have logic in there in case
> SELECT @@servername returns a SQL NULL.
>
> Dave Wolf
> Sybase Professional Services
>
> Don Blair wrote:
>
> > Thanks.
> >
> > I've discovered that you can find the server name
> > with this query:
> >
> > SELECT @@servername
> >
> > Don
> > --------------------------------
> > David Wolf wrote:
> > >
> > > Don,
> > >
> > > Why not create a statement object or a PreparedStatement object and
> > > place the 'select db_name()' SQL function into it. The use it at
> > will
> > >
> > > Dave Wolf
> > > Sybase Professional Services
> > >
> > > Don Blair wrote:
> > >
> > > > Can jConnect tell you the name of the server & database
> > > > you're connected to?
> > > >
> > > > For instance, suppose the user connects to this URL:
> > > >
> > > > jdbc:sybase:Tds:donspc:4444
> > > >
> > > > I'd like to be able to find the name of the server
> > > > & database that I reached.
> > > >
> > > > When jConnect supports JNDI, then I can pull the
> > > > server name out of the URL. However, I will still
> > > > need help on the database name.
> > > >
> > > > Don