• Register
search
Log In
0 votes
92 views

Problem :

I am facing bellow error

java.sql.sqlrecoverableexception no more data to read from socket

6.9k points

2 Answers

0 votes

Solution :

I was able to solve this problem from application side, under the bellow scenario:

I used the database connection pooling apache tomcat-jdbc:

You can also take the following configuration parameters as a reference:

<Resource name="jdbc/exampleDB"
      auth="Container"
      type="javax.sql.DataSource"
      factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
      testWhileIdle="true"
      testOnBorrow="true"
      testOnReturn="false"
      validationQuery="SELECT 1 FROM DUAL"
      validationInterval="30000"
      timeBetweenEvictionRunsMillis="30000"
      maxActive="100"
      minIdle="10"
      maxWait="10000"
      initialSize="10"
      removeAbandonedTimeout="60"
      removeAbandoned="true"
      logAbandoned="true"
      minEvictableIdleTimeMillis="30000"
      jmxEnabled="true"
      jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;
        org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
      username="your-username"
      password="your-password"
      driverClassName="oracle.jdbc.driver.OracleDriver"
      url="jdbc:oracle:thin:@localhost:1521:xe"/>

This configuration was sufficient to fix the error. This works fine for me in the scenario mentioned above.

Further Readings:

36.1k points
0 votes

Solution:

Reason:

This error notify an abort of a process, and the first step in resolving this error is to view in the alert log and seek for a trace file.  The "no more data to read from socket" is not a JDBC or an Oracle error. More, it is a generic communications error, mostly as the result of a TNS connectivity issue.

The "no more data to read from socket" error is most often since of an Oracle bug (in 11g) and we recommend moving to the latest release of Oracle.

For errors like this you must employ oracle support. Unfortunately you do not reference what oracle release you are exercising. The error can be concerned to optimizer bind peeking. Relying on the oracle version different workarounds apply.

You have two methods to address this:

  1. upgrade to 11.2
  2. set oracle parameter 
    _optim_peek_user_binds = false

    Naturally underscore parameters must just be set in case advised by oracle support

Another example: In case you are sending date parameters to a parameterized sql, ensure that you sent java.sql.Timestamp and not java.util.Date. Otherwise you will obtain

java.sql.SQLRecoverableException: No more data to read from socket

Example statement: In our java code, we are employing org.apache.commons.dbutils and we have the following:

final String sqlStatement = "select x from person where date_of_birth between ? and ?";
java.util.Date dtFrom = new Date(); //<-- this will fail
java.util.Date dtTo = new Date();   //<-- this will fail
Object[] params = new Object[]{ dtFrom , dtTo };
final List mapList = (List) query.query(conn, sqlStatement, new MapListHandler(),params); 

The above was impotence until we altered the date parameters to be java.sql.Timestamp

java.sql.Timestamp tFrom = new java.sql.Timestamp (dtFrom.getTime()); //<-- this is OK
java.sql.Timestamp tTo = new java.sql.Timestamp(dtTo.getTime());   //<-- this is OK
Object[] params = new Object[]{ tFrom , tTo };
final List mapList = (List) query.query(conn, sqlStatement, new MapListHandler(),params); 

Attempt two things:

  1. Place in $ORACLE_HOME/network/admin/tnsnames.ora on the oracle server server=dedicated to server=shared to approve more than one connection simultaneous. Restart oracle.

  2. In case you are employing Java this might help you: In java/jdk1.6.0_31/jre/lib/security/Java.security change securerandom.source=file:/dev/urandom to securerandom.source=file:///dev/urandom

12.8k points
edited by

Related questions

2 votes
1 answer 13 views
13 views
Problem: I am beginner to jTable. I have already attached the jTable to JDBC database. But I don&rsquo;t know how to retrieve them. My requirement is the saved data must be shown if I restart my program but currently it is not working for me. I have ... studentName"); String myshool = myrs.getString("schoolName"); String myjoining = myrs.getString("joiningDate"); } Can somebody solve my problem ?
asked Mar 24 morrisBson 3.2k points
0 votes
1 answer 709 views
709 views
Problem : I want to configure the hibernate orm mapping tool to my java class and want to use PostgreSQL as my database also I have configured the password as "password". But when I tried to run the application, I am facing following error ... in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
asked Dec 4, 2019 alecxe 7.5k points
0 votes
1 answer 228 views
228 views
Problem : I am trying to display Data from DB.But facing error as followsthe server encountered an unexpected condition that prevented it from fulfilling the request.
asked Nov 15, 2019 peterlaw 6.9k points
0 votes
2 answers 103 views
103 views
Problem : I am new to the Spring and JPA, wasted 10 days and no result with the searching on internet. I want to save the object to SQL SERVER, my connection is correct but when I write .flush() I get below exception &ldquo;nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress&rdquo;
asked Jan 21 jwilliam 3.9k points
0 votes
1 answer 101 views
101 views
Problem : I am new to Spring and JPA I want to save object to SQL SERVER, connection is correct but when I write .flush() I get the exception as below javax.persistence.TransactionRequiredException: no transaction is in progress
asked Oct 22, 2019 peterlaw 6.9k points