4 messages in com.mysql.lists.javaRe: MetaData and the Database Name| From | Sent On | Attachments |
|---|---|---|
| Gary Affonso | 06 Nov 2004 12:14 | |
| Mark Matthews | 06 Nov 2004 13:08 | |
| Gary Affonso | 22 Nov 2004 17:23 | |
| Gary Affonso | 22 Nov 2004 17:31 |
| Subject: | Re: MetaData and the Database Name![]() |
|---|---|
| From: | Gary Affonso (gw...@greywether.com) |
| Date: | 11/22/2004 05:23:48 PM |
| List: | com.mysql.lists.java |
Mark,
Belated thanks to you.
The "getCatalog" trick did it.
More specifically, if you have a DatabaseMetaData object (as I do) then you have to grab the connection from it before doing getCatalog. For posterity, the call to the dbmd object that'll get you the database name looks like this:
dbmd.getConnection().getCatalog() );
I always wondered what the hell a "catalog" was. Apparently it's synonymous for "database".
Thanks again!
- Gary
On 11/6/04 1:09 PM, "Mark Matthews" <ma...@mysql.com> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Gary Affonso wrote:
Please forgive, yet another metadata question for the list...
Am I blind, or is there no way to query JDBC MetaData for the name of the database?
I know the db-name is something that's part of the connection string, but in some cases the connection string arrives to my app "fully written" so extracting just the db-name from the connection string means doing some parsing, which I'd prefer to avoid.
Isn't there a metadata method of getting the name of the database to which you're connected?
Thanks!
- Gary
Gary,
Use Connection.getCatalog()
-Mark
- -- Mark Matthews MySQL AB, Software Development Manager - Client Connectivity Office: +1 708 332 0507 www.mysql.com
See you at MySQL ComCon November 8-10! mysqlcomconeurope.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBjT12tvXNTca6JD8RAi/lAJ0fawW3myS2V8tA1djuBE34oBIIdgCgiG++ CGiOjiaiFixOmjCGwsGNGZc= =3HMO -----END PGP SIGNATURE-----




