Null Parameterdata resolved in stmt.getParameterMetaData().getParameterTypeName [OJDBC 19.3]

Viewed 39

I'm using Oracle JDBC driver 19.3 (thin). I have to do some pre-processing like changing the date field format before the query is executed on the DB by the JDBC driver.

To achieve that, I used the PreparedStatement.getParameteMetaData(). I found that for simple queries, I can see the metadata, but for queries having cast functions, BETWEEN, JOINs the metadata returned is null.

For example:

PreparedStatement stmt = conn.prepareStatement(“SELECT MAX(OBJECTID) FROM TEST_CHAR WHERE STATUSCODE = ? AND LABELKEY BETWEEN ? AND ? ”);
ParameterMetaData metadata = stmt.getParameterMetaData().getParameterTypeName(1);      // returns null

PreparedStatement stmt = conn.prepareStatement(“SELECT MAX(OBJECTID) FROM TEST_CHAR WHERE STATUSCODE = ? AND LABELKEY = TO_CHAR(?) ”);
ParameterMetaData metadata = stmt.getParameterMetaData().getParameterTypeName(1);      // returns null

For simple query like below we are able to get the metadata,

PreparedStatement stmt = conn.prepareStatement(“SELECT MAX(OBJECTID) FROM TEST_CHAR WHERE STATUSCODE = ? AND LABELKEY = ? ”);
ParameterMetaData metadata = stmt.getParameterMetaData().getParameterTypeName(1);      // returns “CHAR”

Can you help me in knowing is there a way to get the metadata for all type of queries.

0 Answers
Related