A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
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:
dbMeta = conn.getMetaData();
cols = dbMeta.getColumns(null, null, tablename, columnname);
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
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
How get rowId in a select statement?
IS NULL selection to CMP Entity EJB from DB
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013