This discussion is archived
4 Replies Latest reply: Jul 23, 2012 11:56 AM by rukbat RSS

Unpredictable problems with getting connection

793331 Newbie
Currently Being Moderated
Hello,

Please help me with following issue, that makes me pretty angry:

I'm connecting to Oracle 11g database which is not in my responsibility (Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production)

My Tomcat application uses JDK 1.6 version and JDBC driver (Oracle JDBC Driver version - "11.1.0.7.0" for JDK 1.6, Implementation-Time: Thu Aug 28 18:32:51 2008)

From time to time is not possible to access DB because of "connection time out" or "Closed Connection", happens during calling createStatement method:

java.sql.SQLException: Closed Connection
     at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:120)
     at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:137)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:250)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:330)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:355)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:598)
     at oracle.jdbc.driver.PhysicalConnection.createStatement(PhysicalConnection.java:3904)
     at oracle.jdbc.driver.PhysicalConnection.createStatement(PhysicalConnection.java:3849)

OR

java.sql.SQLRecoverableException: Io exception: Connection timed out
     at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:281)
     at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:137)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:250)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:330)
     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:708)
     at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:1064)
     at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:1146)
     at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1472)
     at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3889)
     at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3959)
     at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:4515)

Application server is unix 64 bit processor, but the same message I recognized also in windows environment.

Recently was installed 64bit processor, some network and firewall changes, oracle patches installed. I tried to search forums but no good solution yet.

There are checked pooled connections every 15 minutes by calling method createStatement on connection. E.g. 10 hours that works without any problems then suddenly exception occures. Timeout for getting connection is set to 5 minutes.

Thank you for help!

Juraj

Edited by: user10853418 on Aug 24, 2010 1:04 AM
  • 1. Re: Unpredictable problems with getting connection
    937847 Newbie
    Currently Being Moderated
    Have you had any solution on this issue?
    I'm having the same problem... but i don't get the "connection timed out" just, and suddenly (!), the "Closed Connection" or the connections closes and it isn't there when trying to execute the query.

    My code is working right when using the OJDBC Statement class, but when I use the CallableStatement class it's doing this. It seems to happen when I try to execute the same query two times... but I can't figure out why this is, or if the connection can suddenly broke down if an error occurs or something...

    Here is the code I'm trying to run.

    Code without problems:
     Statement stmt = conn.createStatement();
     ResultSet rset = stmt.executeQuery(columnsSQL);
    Code WITH problems:
     String plsqlBlock = (String) blocks.next(); //get the plsql code from a file - this is working just fine
     CallableStatement cs = (CallableStatement) conn.prepareCall("begin execute immediate ?; end;"); 
     cs.setString(1, plsqlBlock);
     int res = cs.executeUpdate();
    Could anyone, please, give me a clue?     
    Thanks in advance!
    Regards,
    Carolina.-
  • 2. Re: Unpredictable problems with getting connection
    rp0428 Guru
    Currently Being Moderated
    Welcome to the forum!
    >
    Have you had any solution on this issue?
    . . .
    I'm having the same problem
    . . .
    Could anyone, please, give me a clue?
    >
    One clue is the date of the thread - it is almost two years old. Chances are the original poster is long gone either having solved the problem or abandoned it. Generally you should not resurrect old threads.

    The problem is that you then use another persons thread to try to get your own question answered. This is called HIJACKING the thread and is not appropriate. Read the FAQ on how to post a question and for forum etiquette.

    If you have a problem create your own question. And, since the question involves the database and Java provide the 4 digit Oracle version you are using, the JDK version and the ODBC jar file version. Also post the code that is creating the connection and/or having the problem.
  • 3. Re: Unpredictable problems with getting connection
    937847 Newbie
    Currently Being Moderated
    Oh, I'm sorry, it wasn't on porpouse... I tought that the user who posted maybe had a solution already.

    I've just posted it as: "No more data to read from socket" random SQLException on JDBC


    Thanks!
    Carolina.-

    Edited by: 934844 on 23-jul-2012 10:31
  • 4. Re: Unpredictable problems with getting connection
    rukbat Guru Moderator
    Currently Being Moderated
    Moderator Action:
    This thread is locked as a perfect example of what NOT to do
    (hijack some else's thread just because you can't be bothered being prepared to participate properly in an online forum).

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points