Java SQLException:oracle 中的协议冲突
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29372626/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQLException: Protocol Violation in oracle
提问by Saurav
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)
JDBC Driver used: 12.1.0.1
Java used: jdk1.7.0.65 32-bit
使用的 Oracle 版本:Oracle 11g R2 (11.2.0.3.0) 使用的
JDBC 驱动程序:12.1.0.1
使用的 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) 在 oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207) 在 oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement)或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) 在 oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493)
回答by Jean de Lavarene
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. As of today the latest is 12.1.0.2.
您可以随时尝试使用最新的 JDBC 瘦驱动程序,希望该错误能够得到解决。截至今天,最新版本是 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.
如果这没有帮助,那么您需要联系 Oracle 支持。您将被要求的第一件事是提供发生此错误的连接的 sqlnet 跟踪。这将有助于 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.
祝你好运。
回答by Pierluigi Vernetto
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 连接来自连接池,请始终确保在保留时测试连接。
回答by Tian Na
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 和错误的原因之一。
回答by AVA
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:
就我而言,使用 PreparedStatement 的 getGeneratedKeys() 获取当前序列值会导致协议违规异常。将其替换为从序列中获取序列当前值,如下所示:
String curSeqValQuery = "SELECT seq_name.CURRVAL FROM DUAL";
...
statement = con.prepareStatement(curSeqValQuery);
resultSet = (OracleResultSet) statement.executeQuery();
...
resolved the issue.
解决了这个问题。
回答by YoYo
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.
这通常表示损坏的 tcp/ip 流量。这可能是由于注入的流量或丢弃的数据包造成的。做一个ifconfig
看看你的任何网络接口是否受到异常大量丢弃的数据包的影响。为避免出现问题,当您指出数据库和 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 相匹配应该不会太困难。
回答by Santhosh Aella
The Issue fixed in ojdbc7.jar - version 12.1.0.2 (version you can check in META-INF file of jar)
ojdbc7.jar 中已修复的问题 - 版本 12.1.0.2(版本可以在 jar 的 META-INF 文件中检查)