3 Replies Latest reply: Oct 5, 2012 8:32 AM by 913779 RSS

    java.sql.SQLException: Socket read timed out

    913779

      // DbTest.java
      <code>

      import java.sql.*;
      import java.io.*;

      public class DbTest
      {
      public static void main(String args[])
      {
      System.out.println("DbTest main(-)");
      Connection con = null;
      try
      {
      Class.forName("oracle.jdbc.driver.OracleDriver");
      System.out.println("class loaded");
      con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcldb","scott","tiger");
      System.out.println("con obj created");

      System.out.println("con obj retrived");
      if (con!=null)
      {
      System.out.println("Connection created successfully");

      }
      else
      {
      System.out.println("Connection refused");
      }
      }
      catch (SQLException e)
      {
      e.printStackTrace();
      }
      catch(Exception e)
      {
      e.printStackTrace();
      }
      }
      }

      </code>
      e:\JavaPrgms\JDBC>javac DbTest.java

      e:\JavaPrgms\JDBC>java DbTest
      DbTest main(-)
      class loaded
      java.sql.SQLException: Socket read timed out
      at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)
      at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
      531)
      at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)
      at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio
      n.java:32)
      at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
      at java.sql.DriverManager.getConnection(DriverManager.java:582)
      at java.sql.DriverManager.getConnection(DriverManager.java:185)
      at DbTest.main(DbTest.java:17)
      Caused by: oracle.net.ns.NetException: Socket read timed out
      at oracle.net.ns.Packet.receive(Packet.java:320)
      at oracle.net.ns.NSProtocol.connect(NSProtocol.java:286)
      at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1042)
      at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:301)
      ... 7 more


      i am using win 7 64bit os , Oracle 11.2, Jdk 1.7 how can i resolve this problem?

      Edited by: 910776 on Oct 4, 2012 10:49 AM

        • 1. Re: java.sql.SQLException: Socket read timed out
          rp0428
          Your other thread got locked because all you did was post a bunch of code without explaining what your question or issue was or what the code is supposed to be doing.
          java.sql.SQLException: Socket read timed out

          Simply reposting in this forum isn't enough. Edit your post and and add \
           tags on the line before and the line after the code to preserve the formatting.
          
          Also explain what you are trying to do, the problem you are having and answer the questions I ask you in your other thread.
          {quote}
          What is it you are trying to do?
          
          Why are you trying to connect to two different databases?
          
          Do either of those databases actually exist?
          
          Do they exist on the local machine that Java is running on?
          
          Can you connect to either of them without using Java?
          {quote}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
          • 2. Re: java.sql.SQLException: Socket read timed out
            @ O.P.,
            You also seemed to have abandoned this same connectivity question when you posted it eight months earlier.
            Re: java.sql.SQLException: The Network Adapter could not establish the connecti

            I suggest you make up your mind to actually work it through to completion for a change.
            • 3. Re: java.sql.SQLException: Socket read timed out
              913779
              8 months earlier error was diff now error is diff first check it and then tell me..

              So, here i want to create my java.sql.Connection object but socket is reading continuously i checked in both 10g and 11g both i am getting same problem. driver class is loading successfully but connection is not establishing.. i got this problem after intalling Windows 7 64bit with Oracle11.2g 64bit and Oracle 10.2 x64 , and same code i tried with mysql its working properly by only changing driver class name and url .. so tell me where is the problem?


              i checked in tnslistener.ora entry there

              my port no is "1521 " and my sid is :"orcldb" as well as my all the services related to oracle are also in starting mode i run oracle from my start>run > sqlplus> its working properly .. so i unable to identify the problem for establishing connection with oracle driver..

              Edited by: 910776 on Oct 5, 2012 6:30 AM