Skip to content

Return CLOB columns as text in the JDBC Request - #6936

Open
apoorv601singhal wants to merge 1 commit into
apache:masterfrom
apoorv601singhal:jdbc-clob-to-string
Open

apoorv601singhal wants to merge 1 commit into
apache:masterfrom
apoorv601singhal:jdbc-clob-to-string

Conversation

@apoorv601singhal

Copy link
Copy Markdown

The JDBC Request appended rs.getObject() to the response and to the variables, so CLOB columns showed up as the toString() of the driver's Clob (e.g. oracle.sql.CLOB@1b2c3d). CLOB columns are now read as text, reusing the conversion that CLOB out parameters of callable statements already had.

While extracting that conversion into clobToString(), I also fixed the cut-off read of large CLOBs: it called getCharacterStream(0, ...), but CLOB positions start at 1, so it failed for every CLOB above jdbcsampler.max_retain_result_size.

Motivation and Context

Fixes #6106

How Has This Been Tested?

Added two tests to JDBCSamplerTest with a mocked ResultSet returning a javax.sql.rowset.serial.SerialClob:

  • a small CLOB is returned as text in the response and in the body_1 variable
  • a CLOB above the retain size is cut off at the retain size

Without the change both fail (the response contains javax.sql.rowset.serial.SerialClob@...). All tests of :src:protocol:jdbc and ./gradlew style pass with JDK 21.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.

processRow appended rs.getObject() to the response and the variables,
so CLOB columns showed up as the toString() of the driver's Clob, like
oracle.sql.CLOB@1b2c3d. Read them as text, the way CLOB out parameters
of callable statements already are.

The cut-off read of large CLOBs started at position 0, but CLOB
positions start at 1, so it failed for every CLOB above the retain size.

Fixes apache#6106
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Converter: CLOB to String

1 participant