This blog is mainly about Java...

Friday, February 24, 2017

java.sql.SQLException: Protocol Violation [14, 62]

Apparently there is a bug in OJDBC 7 Oracle Driver version 12.1.0.1.0.
Take a look at https://confluence.atlassian.com/confkb/confluence-and-oracle-fail-with-protocol-violation-and-could-not-get-clob-value-for-col-errors-780863295.html

The stacktrace in question is this:
Caused by: java.sql.SQLException: Protocol Violation [ 14, 62, ]
 at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:669) ~[ojdbc7-12.1.0.1.jar!/:12.1.0.1.0]
 at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249) ~[ojdbc7-12.1.0.1.jar!/:12.1.0.1.0]
 at oracle.jdbc.driver.T4C8TTIClob.read(T4C8TTIClob.java:245) ~[ojdbc7-12.1.0.1.jar!/:12.1.0.1.0]
 at oracle.jdbc.driver.T4CConnection.getChars(T4CConnection.java:3901) ~[ojdbc7-12.1.0.1.jar!/:12.1.0.1.0]
 at oracle.sql.CLOB.getChars(CLOB.java:517) ~[ojdbc7-12.1.0.1.jar!/:12.1.0.1.0]
 at oracle.sql.CLOB.getSubString(CLOB.java:354) ~[ojdbc7-12.1.0.1.jar!/:12.1.0.1.0]
 at oracle.jdbc.driver.ClobAccessor.getString(ClobAccessor.java:454) ~[ojdbc7-12.1.0.1.jar!/:12.1.0.1.0]
 at oracle.jdbc.driver.GeneratedStatement.getString(GeneratedStatement.java:327) ~[ojdbc7-12.1.0.1.jar!/:12.1.0.1.0]
 at oracle.jdbc.driver.GeneratedScrollableResultSet.getString(GeneratedScrollableResultSet.java:882) ~[ojdbc7-12.1.0.1.jar!/:12.1.0.1.0]
 at org.springframework.jdbc.support.lob.DefaultLobHandler.getClobAsString(DefaultLobHandler.java:181) ~[spring-jdbc-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
 at no.gjensidige.bank.datavarehus.debt.DebtApplication.lambda$run$0(DebtApplication.java:63) [classes!/:0.3]
 at no.gjensidige.bank.datavarehus.debt.DebtApplication$$Lambda$7.328FAEA0.mapRow(Unknown Source) ~[na:na]
 at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93) ~[spring-jdbc-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
 at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60) ~[spring-jdbc-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
 at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:697) ~[spring-jdbc-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
 at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633) ~[spring-jdbc-4.3.5.RELEASE.jar!/:4.3.5.RELEASE]
 ... 20 common frames omitted



There are 3 actions that can be taken to avoid this bug:

  1. Use the JDBC driver version 12.1.0.2.0 which seems to fix this bug
  2. Install the patch provided in the Oracle support page. (this is only available to customers with a valid Oracle support license). Download and apply Patch 17976703 from Support Portal -> Patches & Updates Section.
  3. Switch back to the OJDBC 6 driver which doesn't have this bug.

No comments:

Labels