简体   繁体   English

SQLException:oracle 中的协议冲突

[英]SQLException: Protocol Violation in oracle

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.我有一个在 RedHat Linux 上运行的应用程序。数据库和应用程序共同驻留在机器上。

Oracle version used: Oracle 11g R2 (11.2.0.3.0)使用的 Oracle 版本:Oracle 11g R2 (11.2.0.3.0)
JDBC Driver used: 12.1.0.1使用的 JDBC 驱动程序:12.1.0.1
Java used: jdk1.7.0.65 32-bit使用的Java:jdk1.7.0.65 32位

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?我遇到过很多论坛,其中有人指出此错误是驱动程序问题,但在所有这些论坛中,使用的 oracle 版本更高,驱动程序版本较旧,更改驱动程序解决了问题。但就我而言,Oracle 版本较低,但驱动程序版本较高。那么,在这种情况下,驱动程序的较高版本会出现问题吗?

Also, this protocol violation can also arise when the maximum number of connections on the DB is reached ?此外,当达到 DB 上的最大连接数时,也会出现这种违反协议的情况?

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) java.sql.SQLException:协议违规:[72] at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:464) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTTIfun.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)oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207) 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 or .jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3628) at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493)

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.应用程序内存不足,由于代码中的逻辑导致抛出无关的异常,因此 OutOfMemory 错误丢失。

One of the reasons applications shouldn't handle throwables and errors.应用程序不应处理 throwables 和错误的原因之一。

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).此类错误表明 JDBC 瘦驱动程序中存在错误,该错误无法理解服务器在线路(套接字)上返回的内容。

You can always try to use the very latest JDBC thin driver hoping that the bug will be resolved.您可以随时尝试使用最新的 JDBC 瘦驱动程序,希望该错误能够得到解决。 As of today the latest is 12.1.0.2.截至今天,最新版本是 12.1.0.2。

If that doesn't help then you will need to reach out to Oracle support.如果这没有帮助,那么您需要联系 Oracle 支持。 The first thing you will be asked is to provide the sqlnet trace of the connection where this error happened.您将被要求的第一件事是提供发生此错误的连接的 sqlnet 跟踪。 This will help the Oracle engineers understand what was happening on the network when the failure happened.这将有助于 Oracle 工程师了解故障发生时网络上发生的情况。

To turn on sqlnet tracing, edit your sqlnet.ora file on the server and add要打开 sqlnet 跟踪,请编辑服务器上的 sqlnet.ora 文件并添加

TRACE_LEVEL_SERVER = 16 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.祝你好运。

In my case, using getGeneratedKeys() of PreparedStatement to get current sequence value caused the protocol violation exceptions.就我而言,使用 PreparedStatement 的 getGeneratedKeys() 获取当前序列值会导致协议违规异常。 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.解决了这个问题。

ojdbc7.jar 中已修复的问题 - 版本 12.1.0.2(版本可以在 jar 的 META-INF 文件中检查)

This usually indicates corrupted tcp/ip traffic.这通常表示损坏的 tcp/ip 流量。 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.执行ifconfig以查看您的任何网络接口是否受到异常大量丢弃数据包的影响。 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.为避免出现问题,当您指出数据库和 java 程序在同一台机器上运行时,请尝试使用环回接口 127.0.0.1(本地主机),而不是使用外部 IP 连接到数据库,或者相反仅用于一个测试。

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.让驱动程序与安装的 oracle 相匹配应该不会太困难。

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.如果您的 JDBC 连接来自连接池,请始终确保在保留时测试连接。

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.在我的情况下,这发生在我们尝试使用 ojdbc 驱动程序从另一个数据源定位 db 链接提取数据时,我们没有连接到直接数据源。 Once we connected through direct connection instead of using db link the issue stopped to appear.一旦我们通过直接连接而不是使用 db link 进行连接,问题就会停止出现。
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 HTH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM