Search code examples
javajdbcjython

jdbc: Get the SQL Type Name from java.sql.Type code


I have an array with Field Names and jdbc Type codes. (Those int codes that you can find in

http://download.oracle.com/javase/1.4.2/docs/api/constant-values.html#java.sql.Types.BIT

I use a level 4 Driver.

I can't figure out how to ask the driver for the corresponding SQL (DDL) Type names. It would be useful in jdbc and in native dialects.

I have
(CustomerId, 1) (CustomerName, -8)

and I want

(customerId, INT) (customerId, VARCHAR(200))

Where can I find functions that help me with that? I am using jdbc in jython via zxJDBC, so I can use all java and python DB API 2.0 functionality.


Solution

  • You seem to be using some JDBC metadata methods you have not posted. I believe what you are seeing is the name of the column along with the JDBC type constant from which you can derive the column type. Have a look at the java.sql API to read more on how to get more meta data.