Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    9

    Thumbs up Unanswered: Retrieve Microsoft Access Database Structure

    Respected Sir,
    I want to retrieve the Microsoft Access Database Table Structure using java.Kindly help me by saying how to do it or atleast give me the code for doing it.

    Thanks in advance.

    Regards

    J.Marian Franklin

  2. #2
    Join Date
    Nov 2003
    Location
    Bangalore,India
    Posts
    51

    Hi

    Use resultsetmetadata() function

  3. #3
    Join Date
    Jan 2004
    Location
    Somewhere on the 3rd planet.
    Posts
    13
    import java.io.*;
    import java.sql.*;

    public class TableCols {
    public static void main(String [] args) {

    Connection con;
    Statement stt;
    ResultSet rs;
    ResultSetMetaData rsmd;
    int cols;
    try {

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newI nstance();
    try {
    conStud = DriverManager.getConnection("YourDataSource", "YourID", "YourPass");
    } catch (Exception ex) {throw new Exception(ex.getMessage());}

    stt = con.createStatement();

    rs = stt.executeQuery("select * from YourTable");

    rsmd = rs.getMetaData();
    cols = rsmd.getColumnCount();

    for(int i=1; i<cols; i++)
    System.out.println(rsmd.getColumnName(i));

    rs.close();
    stt.close();
    con.close();

    }
    catch (ClassNotFoundException ex) {
    System.out.println("CNFE : "+ex.getMessage());
    }
    catch (SQLException ex) {
    System.out.println("SQL : "+ex.getMessage());
    }
    catch (Exception ex) {
    System.out.println("Exception : "+ex.getMessage());
    }
    }

    }
    Best regards,
    WGM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •