BrianMc1958
asked on
What is best way to get metadata?
Dear Experts,
To get metadata for a particular table within Java, I have been doing this:
String s = "SELECT TOP 1 * FROM " + table_full_name; // just to get metadata
try
{
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(s);
ResultSetMetaData rsmd = rs.getMetaData();
int maxcol = rsmd.getColumnCount();
for (int col = 1; col <= maxcol; col++)
{
// process metadata
}
}
Is there a simpler, more direct method? It seems awkward to have to select a row first...
Thanks,
BrianMc1958
To get metadata for a particular table within Java, I have been doing this:
String s = "SELECT TOP 1 * FROM " + table_full_name; // just to get metadata
try
{
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(s);
ResultSetMetaData rsmd = rs.getMetaData();
int maxcol = rsmd.getColumnCount();
for (int col = 1; col <= maxcol; col++)
{
// process metadata
}
}
Is there a simpler, more direct method? It seems awkward to have to select a row first...
Thanks,
BrianMc1958
For simple JDBC like above, not that I know of but I'd be happy for someone else to correct me...
You could investigate Connection.getMetaData() but that returns a DatabaseMetaData object.
You could investigate Connection.getMetaData() but that returns a DatabaseMetaData object.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You folks are amazing. Thanks!
--BrianMc1958
--BrianMc1958
No split? :(
Nevertheless that's the way to go I think.
Moreover, you don't call rs.next(), so I think you don't really select