File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Head First Android
this week in the
JDBC and Relational Databases
getting column type info from db
Joined: Oct 28, 2008
Dec 23, 2008 13:20:00
I want to get the
info from the DB for a given column name.
is this really the best way to do this:
DatabaseMetaData dbMeta = conn.getMetaData();
cols = dbMeta.getColumns(null, null, tablename, columnname);
ResultSetMetaData rsMeta = cols.getMetaData();
int colType = rsMeta.getColumnType(0); // Hopefully only have one row
This seems very ugly! Is there an easier way. I am also not checking for null objects along the way which I should probably do which would make this more ugly.
Vinod K Singh
Joined: Sep 30, 2008
Dec 24, 2008 08:48:00
ResultSetMetaData is the standard way to get such information. BTW indexes start from 1 not from 0.
I agree. Here's the link:
subject: getting column type info from db
setting default value for a column
Probs with Sybase
IS NULL selection to CMP Entity EJB from DB
How get rowId in a select statement?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015