简体   繁体   中英

How do I get the corresponding constant variable name for the integer value of -101 an Oracle SQL type from ResultSet.getMetaData().getColumnType(i)

How do I get the corresponding constant variable name for the integer value of an Oracle SQL type from ResultSet.getMetaData().getColumnType(i)?

Few examples of constant variables are the following:

        java.sql.Types.VARCHAR: 
        java.sql.Types.NVARCHAR:
        java.sql.Types.LONGVARCHAR:
        java.sql.Types.LONGNVARCHAR:
        java.sql.Types.NUMERIC:
        java.sql.Types.SMALLINT:
        java.sql.Types.BIGINT:
        java.sql.Types.FLOAT:
        java.sql.Types.DOUBLE:
        java.sql.Types.DECIMAL:
        java.sql.Types.DATE:
        java.sql.Types.TIMESTAMP:
        java.sql.Types.TIMESTAMP_WITH_TIMEZONE:
        java.sql.Types.TIME_WITH_TIMEZONE:

But I'm getting a value of -101 for a specific column which is TIMESTAMP WITH TZ. I'm using Oracle by the way.

So, given the value of -101, what is the constant variable should I use for this? I can see that there's something like oracle.sql.TIMESTAMPTZ but it's not an integer but an actual type.

I tried search the entire java.sql.Types and I couldn't find a match for -101.

It's probably a misunderstood between the JDBC specification and the Oracle driver's implementation.

There is an old bug related to this same question on Squirrel's Backlog .

To discover which constant in java.sql.Types is related to a specific integer value, you can use reflection and loop over all constants and find the one who matches.

But in your case, you'll need a work around to translate the - 101 returned by the oracle driver to the 2014 value specified on the TIMESTAMP_WITH_TIMEZONE constant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM