Which Java and java.sql data types map to my specific database types?

Joe Sam Shirah

JDBC is, of necessity, reliant on the driver and underlying DBMS. These do not always adhere to standards as closely as we would like, including differing names for standard Java types. To deal with this, first, there are a number of tables available in the JDK JDBC documentation dealing with types. See How do I map database specific ( non-standard ) types to JDBC types? for more information.

You can also ask the driver and DBMS for this information programmatically, which should be the final word. See How do I extract SQL table column type information? and the examples TypeInfo.java, DataType.java and CreateNewTable.java in the JDBC API Tutorial and Reference, Second Edition. ( For download information, see Are the code examples from the JDBC API Tutorial and Reference, Second Edition available online?. ) These examples deal generically with the DatabaseMetaData.getTypeInfo method. Some of this information, like column type and DBMS specific type name, is also available from ResultSetMetaData for specific columns.

Additionally, with JDBC 2.0 drivers that support the method ( not all do ), ResultSetMetaData also has a getColumnClassName method available.

Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact