zoukankan      html  css  js  c++  java
  • centos7 64位系统jdbc连接oracle报错问题

    这两天发生了一个错误,记录下来。

    报错如下:

    ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLRecoverableException: IO Error: Connection reset
            at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
            at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
            at com.sun.proxy.$Proxy97.selectList(Unknown Source)
            at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
            at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137)
            at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
            at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
            at com.sun.proxy.$Proxy99.selectAll(Unknown Source)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
            at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    Caused by: java.sql.SQLRecoverableException: IO Error: Connection reset
            at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:498)
            at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553)
            at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254)
            at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
            at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528)
            at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310)
            at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203)
            at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:735)
            at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:667)
            at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:482)
            at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
            at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118)
            at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107)
            at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131)
            at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
            at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
            ... 64 common frames omitted


    没有思路,google了一下,找到了解决方案如下:

    I was recently struggling with this exact same problem. I opened a ticket with Oracle and this is what they told me.

    java.security.SecureRandom is a standard API provided by sun. Among various methods offered by this class void
    nextBytes(byte[])
    is one. This method is used for generating random bytes. Oracle 11g JDBC drivers use this API to generate random number during
    login. Users using Linux have been encountering SQLException("Io exception: Connection
    reset").

    The problem is two fold

    1. The JVM tries to list all the files in the /tmp (or alternate tmp directory set by -Djava.io.tmpdir) when
    SecureRandom.nextBytes(byte[]) is invoked. If the number of files is large the
    method takes a long time
    to respond and hence cause the server to timeout

    2. The method void nextBytes(byte[]) uses /dev/random on Linux and on some machines which lack the random
    number generating hardware the operation slows down to the extent of bringing the whole login process to
    a halt. Ultimately the the user encounters SQLException("Io exception:
    Connection reset")

    Users upgrading to 11g can encounter this issue if the underlying OS is Linux which is running on a faulty hardware.

    Cause
    The cause of this has not yet been determined exactly. It could either be a problem in
    your hardware or the fact
    that for some reason the software cannot read from dev/random


    Solution
    Change the setup for your application, so you add the next parameter to the java command:

    -Djava.security.egd=file:/dev/../dev/urandom



    We made this change in our java.security file and it has gotten rid of the error.

  • 相关阅读:
    java内部类
    java接口静态方法
    java接口默认方法
    多人协作项目如何保持代码风格统一
    美帝程序员薪资大曝光!2年经验google facebook员工真实薪资揭秘【2020年版】
    go并发编程by examples
    解决macbook外接显示屏vscode文字变模糊的问题
    zookeeper和kafka集群源码搭建
    zookeeper命令
    kafka简介和术语
  • 原文地址:https://www.cnblogs.com/liuqxFuture/p/10136553.html
Copyright © 2011-2022 走看看