Thursday, November 15, 2012

Oracle JDBC : Protocol violation

We have batch process running on Solaris servers. We have been using this for several months and one day we started getting JDBC Protocol violation exception from these jobs. This errors happens after several successful database operations and each time it occurs with a different operation. Fix is to use 64 bit VM. To use 64 bit VM pass argument -d64 as command line parameter to Java. We are using Oracle 11g R3, Solaris 5.10 and JDK 1.6.0_21-b06.

java -d64 test.Main

This is the stack trace.

java.sql.SQLException: Protocol violation
-----------
-----------
Caused by: java.sql.SQLException: Protocol violation
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:459)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
        at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
        at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1010)
        at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1185)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
        at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
        at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
        at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)

Using 64 bit VM has the downside that it almost doubled memory usage. So had to allocate more memory using -Xmx{size}m option.

To verify whether a JVM is running in 64 bit mode, one can use the jinfo command which comes with JDK. First get the process id of the running process. For this use jps which also comes with JDK.

jinfo

If it gives following error you have to pass -d64 option to it.

Error attaching to process: Attach failed : debuggee is 64 bit, use java -d64 for debugger

jinfo -d64

Then in the output look for sun.arch.data.model If its value is 64 it means it is running in 64 bit mode.

No comments:

Post a Comment