SQLException: Protocol Violation in oracle
Asked Answered
A

7

16

I am getting the "Protocol Violation". I have an application running on RedHat Linux.The database and the application are co-resident on the machine.

Oracle version used: Oracle 11g R2 (11.2.0.3.0)
JDBC Driver used: 12.1.0.1
Java used: jdk1.7.0.65 32-bit

I have come across many forums where this error has been pointed out to be a driver issue but in all those forums the oracle version used was higher and the driver version were older and changing the driver resolved the issue.But in my case the Oracle version is lower but driver version is higher.So , in this case will the higher version of the the driver could be a problem?

Also, this protocol violation can also arise when the maximum number of connections on the DB is reached ?

Error Message:

java.sql.SQLException: Protocol violation: [72] at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:464) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207) at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:884) at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1167) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1289) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3584) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3628) at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493)

Areta answered 31/3, 2015 at 15:37 Comment(4)
is it because your user's password has expired?Chaqueta
@Chaqueta No, The user's password is not expired.Areta
We'll need to see the full error message, not just a two-word summary of it.Wizard
#4685521Utoaztecan
Z
12

Increase the heap space!

I had this exact error appearing randomly.

The application was running out of memory and the OutOfMemory error was lost due to the logic in the code which resulted in an unrelated exception being thrown.

One of the reasons applications shouldn't handle throwables and errors.

Zoroastrianism answered 26/8, 2016 at 10:35 Comment(1)
Had same issue. Monitoring tool dramatically help on such kind of errors...Baroja
H
7

Such an error indicates a bug in the JDBC thin driver which is not able to understand what the server is returning on the wire (socket).

You can always try to use the very latest JDBC thin driver hoping that the bug will be resolved. As of today the latest is 12.1.0.2.

If that doesn't help then you will need to reach out to Oracle support. The first thing you will be asked is to provide the sqlnet trace of the connection where this error happened. This will help the Oracle engineers understand what was happening on the network when the failure happened.

To turn on sqlnet tracing, edit your sqlnet.ora file on the server and add

TRACE_LEVEL_SERVER = 16

which will add a trace file for each connection in your trace director (on the server). Don't do this on a production system because it will slow down the system dramatically and will generate huge amount of traces.

Good luck.

Harwin answered 21/4, 2015 at 18:45 Comment(0)
H
2

In my case, using getGeneratedKeys() of PreparedStatement to get current sequence value caused the protocol violation exceptions. Replacing it with obtain sequence current value from sequence, as follows:

String curSeqValQuery = "SELECT seq_name.CURRVAL FROM DUAL";
...
statement = con.prepareStatement(curSeqValQuery);
resultSet = (OracleResultSet) statement.executeQuery();
...

resolved the issue.

Hyperbolic answered 26/8, 2016 at 10:51 Comment(0)
L
2

The Issue fixed in ojdbc7.jar - version 12.1.0.2 (version you can check in META-INF file of jar)

Lonnie answered 4/10, 2018 at 12:59 Comment(1)
This is valid if you are using clob: #22785620Cyrenaic
E
1

This usually indicates corrupted tcp/ip traffic. This can be due to injected traffic, or dropped packets. Do a ifconfig to see if any of your network interfaces is being affected by an unusual high amount of dropped packets. To avoid issues, as you indicate that database and java program are running on the same machine, try to use the loopback interface 127.0.0.1 (localhost), rather than it's external IP to connect to the database, or the other way around just for a test.

Not researched this further, but I guess it could also happen when driver and database version are too far apart. Getting driver to match installed oracle should not be too difficult.

Expand answered 27/8, 2018 at 15:14 Comment(0)
A
0

It could simply be that the connection is infected or invalid. If your JDBC connection comes from a Connection Pool, always make sure you test the connection upon reserve.

Adrienadriena answered 4/3, 2016 at 9:7 Comment(0)
C
0

In my case this happened when we were trying to extract the data using ojdbc driver targeting db link from another datasource, we were not connecting to the direct datasource. Once we connected through direct connection instead of using db link the issue stopped to appear.
Another thing I noticed is that the issue was happening in a consistent manner when we were trying to extract data from a column that has Chinese/Japanese characters.
Finally, extracting the data in chunks acted as an appropriate solution too.
HTH

Cyrenaic answered 5/2, 2021 at 19:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.