CHAR Datatype Returned Instead Of VARCHAR2 With Oracle Database 12.1.0.2 And JDBC (Doc ID 2000440.1)

Last updated on JUNE 02, 2017

Applies to:

JDBC - Version 12.1.0.2.0 and later
Information in this document applies to any platform.

Symptoms

Java programs running on Oracle Database 12.1.0.2 on AIX platform show resultset Metadata getColumnType giving CHAR instead of VARCHAR2.
The problem occurs when querying a table with a GROUP BY clause on a VARCHAR2 column and a WHERE clause with a constant variable like the query shown below:

Col1 is defined as VARCHAR2 in table TEST. However, JDBC reports the type as CHAR instead of VARCHAR2.

=> With database 10g and JDBC, when querying a table with a GROUP BY clause on a VARCHAR2 column and a WHERE clause with a constant variable : the datatype returned is VARCHAR2.
=> With database 12.1.0.2 and JDBC, when querying a table with a GROUP BY clause on a VARCHAR2 column and a WHERE clause with a constant variable : the datatype returned is CHAR and not VARCHAR2 as it should be.


Independently of the JDBC version, the problem only reproduces against 12.1.0.2 database.  All other database versions lower than 12.1.0.2 do not show the problem.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms