java protocol_java jdbc Protocol violation错误

https://confluence.atlassian.com/confkb/java-sql-sqlexception-protocol-violation-caught-while-accessing-a-page-and-oracle-db-is-used-781393258.html

打开上面链接,看到意思是

Symptom

This exception was happening occasionally. The stack trace had different sql in it which was very confusing. Running the sql with sql plus worked fine.

Root Cause

The exception was thrown when oracle driver was trying to export a CLOB data. This was happening with only few records, not all of them. The data as such was a file. Visually we could not make out what was wrong with that data.

Why we were seeing errors in oracle logs ?

So if this was a driver defect, why did we see the error in oracle trace ? Logically the driver errors should be only confined to application logs. The reasons was that when protocol violation happened, the connection got corrupted. This connection was returned to the connection pool. Any user or job when will use that connection would not work and would experience error. That is why it will happen at random places, with random users

Solution

A short term fix was to change this property in connection pool. We are using DBCP connection pool.

Changed from ds.setTestOnBorrow(false); to ds.setTestOnBorrow(true);

Now when the pool returns a corrupted connection to the pool, before app borrows this connection , it would test for validity. If connection is unusable, pool would discard and then app gets a new/valid connection.

If you enable connection pool logs, you should see the exception which normally is swallowed.

Driver Upgrade

Upgrade to OJDBC 12.1.0.2 from OJDBC 12.1.0.1 solved the problem, even for the problematic rows.

Some other links for reference

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值