Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Question Unanswered: Oracle describe table from jdbc

    Gurus,
    I need to get Table Schema from JDBC. I tried using following, but no luck.
    ...
    stmt = conn.createStatement();
    ResultSet rs1 = stmt.executeQuery("desc mytable");
    while ( rs1.next() ) { //line 36
    System.out.println(rs1.getString(1));
    }
    Here is exception:
    java.lang.NullPointerException
    at createScripts.main(createScripts.java:36)
    Let me know if any idea what going wrong here.
    Thanks.

  2. #2
    Join Date
    Oct 2003
    Posts
    2

    Thumbs up Found alternate solution...

    select COLUMN_NAME, DATA_TYPE, DATA_LENGTH, NULLABLE from USER_TAB_COLUMNS where TABLE_NAME='mytable' order by column_id;

    Above query produces pretty much same output as "desc mytable".

  3. #3
    Join Date
    Feb 2010
    Posts
    4

    Good answer

    thanks a lot for Your SQL.

Posting Permissions

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