8 Replies Latest reply: Aug 12, 2009 6:10 PM by 717054 RSS

    java.sql.SQLException: Io exception: The Network Adapter could not establis

    624354

      Hey,

      I am trying to connect my JSP page with my oracle Database . i got the error as follows

      java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:111)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:254)
      at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:386)
      at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:413)
      at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:164)...........

      help me out in this problem ...

        • 1. Re: java.sql.SQLException: Io exception: The Network Adapter could not esta
          624480
          You need to show us your connection code, so we can figure out if that is where the mistake is.
          • 2. Re: java.sql.SQLException: Io exception: The Network Adapter could not esta
            625330
            import java.sql.*;
            class dbAccess {
            public static void main (String args []) throws SQLException
            {
            DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

            Connection conn = DriverManager.getConnection
            ("jdbc:oracle:thin:@kalyan:1521:oracle", "scott", "tiger");
            // @machineName:port:SID, userid, password

            Statement stmt = conn.createStatement();
            ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
            while (rset.next())
            System.out.println (rset.getString(1)); // Print col 1
            stmt.close();
            }
            }
            ---------- execute ----------
            java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
                 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
                 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
                 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:274)
                 at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:319)
                 at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:344)
                 at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:148)
                 at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
                 at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:545)
                 at java.sql.DriverManager.getConnection(DriverManager.java:512)
                 at java.sql.DriverManager.getConnection(DriverManager.java:171)
                 at dbAccess.main(dbAccess.java:7)
            Exception in thread "main"
            Output completed (1 sec consumed) - Normal Termination
            can anyone help me out what is the problem with my code?
            • 3. Re: java.sql.SQLException: Io exception: The Network Adapter could not esta
              dvohra21
              The Network Adapter exception is caused because:
              1.     The database host name, port number, or database instance name is wrong.
              2.     The database TNSListener has not been started. The TNSListener may be started with the lsnrctl utility.

              C:\>lsnrctl start
              • 4. Multi-threaded prob -  The Network Adapter could not establish the conn
                625412
                I'm getting the following error:

                java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

                However, I'm running a java application and the connection information is correct because I can connect correctly to the database all of the time except when running a large number of threads. I have a singleton spring bean for oracle.jdbc.pool.OracleDataSource and connect through the thin oracle driver. When I have 64 threads simultaneously hitting it for a connection, it eventually gives the above error. If the number of threads is 32, it never encounters it.

                I wanted to know if any one knows of a way to set a connection limit. Is this done from the database side or the java side?
                • 5. Re: Multi-threaded prob -  The Network Adapter could not establish the conn
                  414247
                  You desperately need a connection pooling solution. Making connections
                  on-the-fly is slow, and if you try to make too many in a short period,
                  such as one thread in a tight loop, or many threads making them at
                  once, Oracle's listener gets woverhwelmed temporarily, and will fail
                  some of your identical and validly-formed requests.
                  Joe Weinstein at BEA Systems
                  • 6. Re: Multi-threaded prob -  The Network Adapter could not establish the conn
                    625412
                    Thanks for the reply. We have been trying connection pooling which has been working 98% of the time, but occasionally get quirks. I guess we should re-pursue this and work the problems out.
                    • 7. Re: Multi-threaded prob -  The Network Adapter could not establish the conn
                      625412
                      I turned the connection pooling back on and that gets rid of the problem. I just need to coordinate the pooling limit with the database connection limit.
                      • 8. Re: java.sql.SQLException: Io exception: The Network Adapter could not esta
                        717054
                        lsnrctl start_ works just a like charm. my web server is on a guest o/s with windows server 2008 and my database server is on another guest o/s ubuntu. thanx.