retrieving a list of databases


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: retrieving a list of databases

  1. #1
    Join Date
    Mar 2004
    Posts
    635

    retrieving a list of databases

    I've search everywhere, and nothing seems to answer the question. I don't need a list of tables on a database, but a list of databases on the sql server. At which point I can then choose one to connect to then list its tables.
    Last edited by Phaelax; 11-23-2005 at 08:34 PM. Reason: solved

  2. #2
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    255
    You could check the JDBC API for DatabaseMetaData. There is a method called getCatalogs().
    Happiness is good health and a bad memory.

  3. #3
    Join Date
    Mar 2004
    Posts
    635
    thx, got it.

    For anyone else who's wanted to know:
    Code:
    DatabaseMetaData dbmd = connection.getMetaData();
    ResultSet result = dbmd.getCatalogs();
    while(result.next())
    {
         String tableName = result.getString(1);
         System.out.println(tableName);
    }

Similar Threads

  1. Replies: 0
    Last Post: 11-14-2001, 12:00 PM
  2. ListBot Going Out of Business
    By Larry Rebich in forum vb.announcements
    Replies: 1
    Last Post: 06-28-2001, 01:22 PM
  3. SQL list all databases
    By Rich in forum Database
    Replies: 2
    Last Post: 05-22-2001, 09:20 AM
  4. Replies: 2
    Last Post: 06-14-2000, 03:17 PM
  5. Replies: 0
    Last Post: 06-14-2000, 11:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center