1 Reply Latest reply on Nov 4, 2013 10:18 PM by jschellSomeoneStoleMyAlias

    jdbc connection through client machine

    8a639176-49ef-4646-8606-468629945998

      hello,
      i am new to oracle and also in jdbc i am facing some problem...
      i want to connect to database server from client machine.In client machine jdk1.6 installed and also jdbc thin driver was placed in classpath(ojdbc6_g.jar)
      CODE---

      import java.sql.*;

      import java.lang.*;

      class First

      {

        public static void main(String[] args)throws Exception

        {

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

        System.out.println("driver loaded");

        Connection con=DriverManager.getConnection("jdbc:oracle:thin:@hostname:portno","USERNAME","PASSWORD");

        System.out.println("connected to database");

        Statement st = con.createStatement();

        int c=st.executeUpdate("INSERT INTO ACCOUNT VALUES(1008,'john',6700)");

        System.out.println(c);

        st.close();

        con.close();

        }

      }

      in server machine there is no problem i am connect to db from supplying @localhost but from other machine i cant connect...!!! client machine is connected to server through wifi

      i got the following exception---

       

      Exception in thread "main" java.sql.SQLException: The Network Adapter could not

      establish the connection

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

              at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:

      535)

              at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:218)

              at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio

      n.java:29)

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

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

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

              at First.main(First.java:9)

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

      he connection

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

              at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.j

      ava:419)

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

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

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

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

              ... 7 more

      Caused by: java.net.ConnectException: Connection timed out: connect

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

              at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)

              at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)

              at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)

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

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

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

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

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

              ... 12 more

       

      when i am using ip address in instead of hostname i got these exceptions---

       

      Exception in thread "main" java.sql.SQLException: The Network Adapter could not

      establish the connection

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

              at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:

      535)

              at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:218)

              at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio

      n.java:29)

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

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

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

              at First.main(First.java:9)

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

      he connection

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

              at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.j

      ava:419)

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

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

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

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

              ... 7 more

      Caused by: java.net.ConnectException: Connection timed out: connect

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

              at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)

              at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)

              at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)

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

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

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

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

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

              ... 12 more

      plz help me..???