Originally posted by Venkat Nagam:
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.
Originally posted by Sainudheen Mydeen:
Hi
"desc mytable" is a sql plus command. I am not sure we can use that here to get a ResultSet.
----------------
Sainudheen
Originally posted by da Am:
Actually getTables() method of DatabaseMetaData gives info about a table or tables matching pattern specified. But in this case since the user needs information about columns getColumns() method is more suitable.
Sainudheen Mydeen wrote:Hi
"desc mytable" is a sql plus command. I am not sure we can use that here to get a ResultSet.
----------------
Sainudheen
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |