4

I'm looking for a link to a table with the mappings between SQL types (java.sql.Types) to Java types.

Do you know where I can find one ?

Paul Bellora
  • 54,340
  • 18
  • 130
  • 181
Stephan
  • 41,764
  • 65
  • 238
  • 329
  • 1
    **Update:** As of Java 8 and JDBC 4.2, the `java.sql.Types` class is supplanted by a proper [Java enum](https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html), [`JDBCType`](https://docs.oracle.com/javase/8/docs/api/java/sql/JDBCType.html), implementing the [`SQLType`](https://docs.oracle.com/javase/8/docs/api/java/sql/SQLType.html) interface. Same idea, same values, but with the type-safety and convenience of enums. – Basil Bourque Apr 25 '18 at 04:14

4 Answers4

9

The JDBC 4.x Specification, provided by JSR 221, provides this info in appendix B titled Data Type Conversion Tables.

See tables containing mappings from Java object types to JDBC types. Different tables exist for the mappings that will be performed when different methods of the JDBC API are invoked; for instance, a separate mapping exists for CallableStatement.getObject and ResultSet.getObject while another exists for the mappings used during ResultSet.getXXX methods.

Click through that JSR 221 page to download a PDF of the spec document, currently JDBC 4.3.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Vineet Reynolds
  • 76,006
  • 17
  • 150
  • 174
4

here is a document for Java 6. http://download.oracle.com/javase/6/docs/technotes/guides/jdbc/getstart/mapping.html#996857

Jifeng Zhang
  • 5,037
  • 4
  • 30
  • 43
2

EDIT: Have a look at this article.

It may be better to look for documentation provided by the driver itself, as this will be more definite.

Paul Bellora
  • 54,340
  • 18
  • 130
  • 181
  • It's for the JavaSE 1.3. I'm looking for the JavaSE 6 version of this document. – Stephan Aug 05 '11 at 15:35
  • As I said it comes down to the driver's implementation - oracle is just giving the guidelines. What driver are you using? – Paul Bellora Aug 05 '11 at 15:52
  • I use the JDBC driver of Postgresql. – Stephan Aug 05 '11 at 15:56
  • updated the link for SE 6 (JDBC API 3) Postgresql JDBC unfortunately doesn't seem to have a concrete document on this. – Paul Bellora Aug 05 '11 at 15:58
  • I think this answers the question if you don't mind accepting, however you might ask specifically about how postgresql driver maps arrays if that's your issue. – Paul Bellora Aug 05 '11 at 16:11
  • The anwser is correct. But some types are unclear for me : Types.DATALINK, Types.DISTINCT, Types.JAVA_OBJECT, Types.NULL and Types.OTHER. – Stephan Aug 05 '11 at 16:31
0

This is for the Derby database Sql Types

Shawn Vader
  • 12,285
  • 11
  • 52
  • 61