views:

33

answers:

1
+3  A: 

Don't use Object, but just use the type which is associated with the datatype in question. You can find here more detailed information about which Java object types you should be using for certain DB datatypes with under each this table:

alt text

Alternatively, you can use DatabaseMetaData#getColumns() to figure the column information (column name, datatype, size, maxlength, nullable, etc).

There are lot of other methods which may be of use, e.g. getIndexInfo() to figure all indexes, the getPrimaryKeys() to figure the PK's, the getExportedKeys() to figure the FK's, etcetera. Just poke a bit round in the whole DatabaseMetaData API to find that you need.

BalusC
This was useful but I think ResultSetMetaData is easier. Thoughts?
twodayslate
It contains the same information. You only have to create/prepare a `Statement` and query a `ResultSet` first before you can get it. This makes not much sense. With just the `Connection` you can already get the `DatabaseMetaData`.
BalusC
Oh I see. That is a big benefit. Changing my RSMD stuff to DMD stuff now...
twodayslate
Getting `[Microsoft][ODBC Driver Manager] Driver does not support this function` for a lot of things... but oh well :\
twodayslate
The ODBC bridge driver is indeed a pain in the ass. You can either go for [HXTT JDBC driver](http://www.hxtt.com/access.html) (costs $$$ tho) or replace MSAccess by a real DB server which ships with decent (and free) JDBC drivers.
BalusC
Forced to use access :( I have everything but if it is required or unique. That is all I need left. I can just hard code it I guess...
twodayslate