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.s
JDBCType
& SQLType
With improvements in the API's, as of Java 8 and JDBC 4.2, we have JDBCType and SQLType, and in the same spirit as some of the other examples can be simply used as follows:
String typeName = JDBCType.valueOf(-5).getName();
But of course, why using the numeric types to begin with. Make a habit, and switch over from numeric's to the enum
constants defined in JDBCType
:
String typeName = JDBCType.BIGINT.getName();
et voilà!
However, that might not be enough to have something good enough for using in a DDL ... you might need to implement vendor specific translation. As an example, you might need to consider to translate VARCHAR
to VARCHAR2
in the case of Oracle.