title: Socket read timed out in Oracle JDBC connection
body: <pre><code>import java.sql.*;
  
  public class OracleJDBC {
  
      public static void main(String[] args) {
          String url = "jdbc:oracle:thin:@localhost:1521:TestDB";
          String user = "kdhong";
          String pass = "kdhong";
          Connection conn = null;
          String sql = null;
          String query = null;
          int result;
  
          try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
              System.out.println("success!");
          } catch (ClassNotFoundException e) {
              // TODO Auto-generated catch block
              System.err.println("error1 = " + e.getMessage());
              System.exit(1);
          }
  
          try {
              conn = DriverManager.getConnection(url, user, pass);
              System.out.println("success!");
          } catch (SQLException e) {
              e.printStackTrace();    
          }
  
          try {
              conn.setAutoCommit(false);
              Statement stmt = conn.createStatement();
              sql = "create table testtable(" +
              "id int)";
              result = stmt.executeUpdate(sql);
              if(result == 0)
                  System.out.println("table created!!");
              conn.commit();
              conn.setAutoCommit(true);
              stmt.close();
              conn.close();
          } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
      }
  
  }
  </code></pre>
  
  <p>I am using <strong>Oracle DB 11g</strong> and trying to connect it with my Java application program.
  And I tried this Java code in my eclipse IDE. I installed <strong>ojdbc6</strong> in <strong>jre/lib/ext</strong> folder, and executed this program.
  The class DriverManager was created successfully. But my code hangs on <code>conn=DriverManager.getConnection(url, user, pass);</code> statement. I printed the trace stack.</p>
  
  <pre><code>java.sql.SQLException: Socket read timed out
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)
  at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:531)
  at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:221)
  at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
  at java.sql.DriverManager.getConnection(DriverManager.java:664)
  at java.sql.DriverManager.getConnection(DriverManager.java:247)
  at OracleJDBC.main(OracleJDBC.java:24)
  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
  Exception in thread "main" java.lang.NullPointerException
  at OracleJDBC.main(OracleJDBC.java:31)
  </code></pre>
  
  <p>I already checked out OracleOraDb11g_home1TNSListener service is being serviced. So what kind of other problems can cause this connection problem? </p>