Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 59918 invoked from network); 14 Apr 2010 20:16:04 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 14 Apr 2010 20:16:04 -0000 Received: (qmail 99769 invoked by uid 500); 14 Apr 2010 20:16:04 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 99740 invoked by uid 500); 14 Apr 2010 20:16:04 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 99733 invoked by uid 99); 14 Apr 2010 20:16:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Apr 2010 20:16:04 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of erandajira@gmail.com designates 74.125.83.172 as permitted sender) Received: from [74.125.83.172] (HELO mail-pv0-f172.google.com) (74.125.83.172) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Apr 2010 20:15:58 +0000 Received: by pvf33 with SMTP id 33so372214pvf.31 for ; Wed, 14 Apr 2010 13:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:content-type; bh=M+1w2JogjyDi9SHXEUhYCK7uAhn4sEnD8flCH52b7uw=; b=Tp8PUx9pkiu3Jb8XdYcs7gce84wrBRrNlLCq0zyQO8PWL9yyjnOwyV2Z5+0brQ+lcP hidLygU2sUvfWxv9ALe2pYdW05WM8KTuRdcInVbIlSvYyl1peCrNLszsQUCMYlPFtrWo 01Qq+07akH/qMN+5O6Jh6whBYe8VNv6Fflo8Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=wWS7vlscNLbBBml5y4l+JE9MwZHszSSqzQpxUShvNyy/VwDAbvnOXgJ6MfDwPF+Lb+ UtR7TMasHl6mH1HrOn77tTCxF82+25lzSSEDX3jWYsPKkm4nH+1QDYV2YHUDnXjr9jg5 EUOY9j4OY6d4zJcSXwaIZww69WU0Bqf22QDWw= MIME-Version: 1.0 Received: by 10.142.165.4 with HTTP; Wed, 14 Apr 2010 13:15:37 -0700 (PDT) In-Reply-To: <4BC5790B.9090102@sun.com> References: <4BC5790B.9090102@sun.com> Date: Thu, 15 Apr 2010 01:45:37 +0530 Received: by 10.142.117.2 with SMTP id p2mr3717396wfc.209.1271276137613; Wed, 14 Apr 2010 13:15:37 -0700 (PDT) Message-ID: Subject: Re: Get database name From: Eranda Sooriyabandara To: derby-dev@db.apache.org Content-Type: multipart/alternative; boundary=001636e0a769980b980484380ab9 --001636e0a769980b980484380ab9 Content-Type: text/plain; charset=ISO-8859-1 Hi Knut, Thanks. Also is there a way to get the current database name within the code? The purpose is to print the current database name to the log. Thanks Eranda On Wed, Apr 14, 2010 at 1:42 PM, Knut Anders Hatlen wrote: > On 04/13/10 09:50 PM, Eranda Sooriyabandara wrote: > > Hi, > > Are there any method which we can get the current database instance name? > > EmbedConnection has a public method called getDBName(), but that method > can only be used if you cast the connection instance to EmbedConnection, > and it only works on the embedded driver. If you want to get the > database name through the JDBC interfaces, I think you first need to get > the connection URL, > > String url = conn.getMetaData().getURL(); > > and then extract the database name part from the string. > > -- > Knut Anders > > --001636e0a769980b980484380ab9 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Knut,
Thanks. Also is there a way to=A0get the current database name=A0withi= n the code?
The purpose is to print the current database name to the log.
Thanks
Eranda

On Wed, Apr 14, 2010 at 1:42 PM, Knut Anders Hat= len <Knut.Hatle= n@sun.com> wrote:
On 04/13/10 09:50 PM, Eranda Sooriyabandara wrote:
>= ; Hi,
> Are there any method which we can get the current database in= stance name?

EmbedConnection has a public method called getDBN= ame(), but that method
can only be used if you cast the connection instance to EmbedConnection,and it only works on the embedded driver. If you want to get the
databa= se name through the JDBC interfaces, I think you first need to get
the c= onnection URL,

String url =3D conn.getMetaData().getURL();

and then extract the= database name part from the string.

--
K= nut Anders


--001636e0a769980b980484380ab9--