7 Replies Latest reply: Jul 27, 2014 3:41 PM by dvohra21 RSS

    IO Error configuring JDBC for localhost database

    Jose Aróstegui

      Hi experts,

       

      I'm configuring a new test environment in a linux host and I've detected that when using RCU or create a new Weblogic domain or create a new JDBC connection I'm getting this error:

       

      IO Error: The Network Adapter could not establish the connection<br/>oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:800)<br/>oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793)<br/>oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)<br/>oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:614)<br/>weblogic.jdbc.common.internal.DataSourceUtil.testConnection0(DataSourceUtil.java:340)<br/>weblogic.jdbc.common.internal.DataSourceUtil.access$000(DataSourceUtil.java:22)<br/>weblogic.jdbc.common.internal.DataSourceUtil$1.run(DataSourceUtil.java:254)<br/>java.security.AccessController.doPrivileged(Native Method)<br/>weblogic.jdbc.common.internal.DataSourceUtil.testConnection(DataSourceUtil.java:251)<br/>com.bea.console.utils.jdbc.JDBCUtils.testConnection(JDBCUtils.java:751)<br/>com.bea.console.actions.jdbc.datasources.createjdbcdatasource.CreateJDBCDataSource.testConnectionConfiguration(CreateJDBCDataSource.java:479)<br/>sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br/>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)<br/>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br/>java.lang.reflect.Method.invoke(Method.java:606)<br/>org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:870)<br/>org.apache.beehive.netui.pageflow.FlowController.getActionMethodForward(FlowController.java:809)<br/>org.apache.beehive.netui.pageflow.FlowController.internalExecute(FlowController.java:478)<br/>org.apache.beehive.netui.pageflow.PageFlowController.internalExecute(PageFlowController.java:306)<br/>org.apache.beehive.netui.pageflow.FlowController.execute(FlowController.java:336)<br/>...


      if I use "locahost" as name of the server


      It's strange for my as this is not the first enviroment I set up and I've always used "localhost" as server name without any connection problem.


      Any idea?

       

      My weblogic version is 12.1.3

       

      Thanks in advance,
      Jose.

        • 1. Re: IO Error configuring JDBC for localhost database
          Bhargavim-Oracle

          Hi Jose,

           

          You mentioned you are using "localhost" as the DB Server host. Is your DB running on the same machine where you are trying to create WLS domain/connection pool?

           

          Can you connect to the DB connection url using a SQL client (using localhost)?

           

          The Network Adapter could not establish the connection - simply means that the client cannot reach DB instance with the DB connection url mentioned in JDBC pool configuration or DB instance is down.

           

          Thanks,

          Bhargavi

          • 2. Re: IO Error configuring JDBC for localhost database
            Jose Aróstegui

            Yes, of course both are in the same machine.

             

            I can connect perfectly using sql*plus in the server, so the database is up. My question is how does WL resorlve the jdbc url to connect to the DB? Maybe is due to some misconfiguration in the host? the /etc/hosts seems to be OK...

            • 3. Re: IO Error configuring JDBC for localhost database
              Luz Mestre-Oracle

              Hi Jose

              You can try testing using dbping

              2 Using the Oracle WebLogic Server Java Utilities (12c (12.1.3))

              If you are able to connect to the database, you can use the same information used in dbping to create your datasource.

              Also, Does database utility tnsping work for you?

               

              Best Regards

              Luz

              • 4. Re: IO Error configuring JDBC for localhost database
                Jose Aróstegui

                Thanks a lot for your help, Luz.

                 

                It fails when using localhost, but not when I use machinename or machinename.domainname:

                 

                java utils.dbping ORACLE_THIN xxx yyy localhost:1521:XE

                 

                 

                Error encountered:

                 

                 

                java.security.PrivilegedActionException: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection

                        at java.security.AccessController.doPrivileged(Native Method)

                        at utils.dbping.getConnection(dbping.java:292)

                        at utils.dbping.main(dbping.java:258)

                Caused by: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection

                        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:800)

                        at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:793)

                        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)

                        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:614)

                        at java.sql.DriverManager.getConnection(DriverManager.java:571)

                        at java.sql.DriverManager.getConnection(DriverManager.java:187)

                        at utils.dbping$1.run(dbping.java:295)

                        ... 3 more

                Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection

                        at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:475)

                        at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:569)

                        at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:620)

                        at oracle.net.ns.NSProtocol.connect(NSProtocol.java:239)

                        at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1606)

                        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:539)

                        ... 9 more

                Caused by: java.net.ConnectException: Connection refused

                        at java.net.PlainSocketImpl.socketConnect(Native Method)

                        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)

                        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)

                        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)

                        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

                        at java.net.Socket.connect(Socket.java:579)

                        at oracle.net.nt.MetricsEnabledSocket.connect(TcpNTAdapter.java:660)

                        at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:174)

                        at oracle.net.nt.ConnOption.connect(ConnOption.java:162)

                        at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:431)

                        ... 14 more

                       

                java utils.dbping ORACLE_THIN xxx yyy machine:1521:XE  or  java utils.dbping ORACLE_THIN xxx yyy machine.domain:1521:XE

                 

                 

                **** Success!!! ****

                 

                 

                You can connect to the database in your app using:

                 

                 

                  java.util.Properties props = new java.util.Properties();

                  props.put("user", xxx);

                  props.put("password", yyy);

                  java.sql.Driver d =

                    Class.forName("oracle.jdbc.OracleDriver").newInstance();

                  java.sql.Connection conn =

                    Driver.connect("xxx", props);

                • 5. Re: IO Error configuring JDBC for localhost database
                  Luz Mestre-Oracle

                  Thanks Jose for the feedback... It seems to be database configuration, you might want to check tnsnames.ora.

                  Best Regards

                  Luz

                  • 6. Re: IO Error configuring JDBC for localhost database
                    Jose Aróstegui

                    Hi Luz,


                    Yes you were right, but the problem was in the listener.ora. To be more specific, I've changed the ip for the host name and domain:

                     

                    Before:

                    LISTENER =

                      (DESCRIPTION_LIST =

                        (DESCRIPTION =

                          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))

                          (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.yyy.zzz.hhh )(PORT = 1521))

                        )

                      )

                    After:

                    LISTENER =

                      (DESCRIPTION_LIST =

                        (DESCRIPTION =

                          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))

                          (ADDRESS = (PROTOCOL = TCP)(HOST = myhost.mydomain)(PORT = 1521))

                        )

                      )

                     

                    Thanks a lot for your help!

                    • 7. Re: IO Error configuring JDBC for localhost database
                      dvohra21

                      java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection


                      The Network Adapter could not establish the connection exception is caused by one or more of the following configuration errors:

                      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 lsnrctlutility.
                      C:>lsnrctl start