Results 1 to 2 of 2
  1. #1
    sandeepsai17 is offline Member
    Join Date
    Jun 2009
    Posts
    30
    Rep Power
    0

    Default problem with getting alll schema names from database

    hi to all
    my problem is i am unable to get list of schemas in my database using java code .
    Here is my code
    Java Code:
    import java.sql.*;
    public class ListSchemas {
      public static void main(String [] args) {
        Connection con = null;
        try {    
          Class.forName("com.mysql.jdbc.Driver");
          con = DriverManager.getConnection("jdbc:mysql://localhost","root","ssahmsb97");
          
          DatabaseMetaData meta = con.getMetaData();
          ResultSet res = meta.getSchemas();
          System.out.println("List of schemas: "); 
          while (res.next()) {
             System.out.println(
                "   "+res.getString("TABLE_SCHEM") 
               + ", "+res.getString("TABLE_CATALOG")); 
          }
          res.close();
          con.close();
        } catch (java.lang.ClassNotFoundException e) {
          System.err.println("ClassNotFoundException: "
            +e.getMessage());
        } catch (SQLException e) {
          System.err.println("SQLException: "
            +e.getMessage());
        }
      }
    please help me what is wrong with above code .

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,750
    Rep Power
    19

Similar Threads

  1. XML Schema
    By Abder-Rahman in forum XML
    Replies: 1
    Last Post: 02-22-2009, 04:33 PM
  2. Merge 2 XMLs Based on Schema
    By wowstartup in forum XML
    Replies: 0
    Last Post: 02-12-2009, 05:46 PM
  3. Graphic library for XML Schema
    By earns in forum XML
    Replies: 0
    Last Post: 10-26-2008, 04:49 PM
  4. Annoying database problem!
    By DC1 in forum New To Java
    Replies: 2
    Last Post: 05-29-2008, 09:43 AM
  5. Problem to connect Database
    By Swamipsn in forum NetBeans
    Replies: 1
    Last Post: 08-07-2007, 07:13 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
  •