Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2012
    Posts
    22

    SqlException : The Network Adapter could not establish connection

    hii,

    I am using Windows Vista 32bit o/s , installed Software Oracle 11.2.0.1
    i am able to execute oracle Type 1 driver by using odbc connection

    Now i want to connect my Java Application with My Oracle Database Software by Type 4 mechanism
    i successfully added "OJDBC6.JAR" file in my class path
    while executing code i got an

    "SqlException : The Network Adapter could not establish connection"

    here is my code..
    Code:
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.SQLException;
    public class OraTestType4
    {
    	public static void main(String[] args) 
    	{
    		try
    		{
    			/*
    			Try
    					DriverManager.registerDriver( new oracle.jdbc.driver.OracleDriver());
    					Connection connection = DriverManager.getConnection("jdbc racle:thin:@202.201.57:1521:myoracle","USER","PASSWORD"); 
    			*/
    		
    		//loading clss from 
    		Class.forName("oracle.jdbc.driver.OracleDriver");
    		//	DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    		// Establishing connectiion with Data base software
    		Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522:orcl","scott","ltiger");
    
    		if (con==null)
    			System.out.println("Connection with Database software is not establish...");
    		else 
    			System.out.println("Connection successfully establish...");
    		}
    		catch (SQLException e)
    		{
    			e.printStackTrace();
    		}
    		catch (ClassNotFoundException e)
    		{
    			e.printStackTrace();
    		}
    		catch (Exception e)
    		{
    			e.printStackTrace();
    		}
    
    	}
    }

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,649
    post results from OS commands below

    lsnrctl status
    lsnrctl service
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    There are no stupid questions, but there are a LOT of Inquisitive Idiots.

  3. #3
    Join Date
    Jan 2012
    Posts
    22
    Quote Originally Posted by anacedent View Post
    post results from OS commands below

    lsnrctl status
    lsnrctl service
    here i attached my output
    Attached Thumbnails Attached Thumbnails Ora-00439.jpg  

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,649
    I am sorry that COPY & PASTE are broken for you.
    I guess I need new glasses since I can not discern details from posted response.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    There are no stupid questions, but there are a LOT of Inquisitive Idiots.

  5. #5
    Join Date
    Jan 2012
    Posts
    22
    Quote Originally Posted by anacedent View Post
    I am sorry that COPY & PASTE are broken for you.
    I guess I need new glasses since I can not discern details from posted response.

    java.sql.SQLException: The Network Adapter could not establish the connection
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnecti on.java:412)
    at oracle.jdbc.driver.PhysicalConnection.<init>(Physi calConnection.java:531)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnect ion.java:221)
    at oracle.jdbc.driver.T4CDriverExtension.getConnectio n(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriv er.java:503)
    at java.sql.DriverManager.getConnection(DriverManager .java:579)
    at java.sql.DriverManager.getConnection(DriverManager .java:221)
    at Orajdbc.main(Orajdbc.java:20)
    Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
    at oracle.net.nt.ConnStrategy.execute(ConnStrategy.ja va:359)
    at oracle.net.resolver.AddrResolution.resolveAndExecu te(AddrResolution.java:422)
    at oracle.net.ns.NSProtocol.establishConnection(NSPro tocol.java:672)
    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:2 37)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnec tion.java:1042)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnecti on.java:301)
    ... 7 more
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(N ative Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Du alStackPlainSocketImpl.java:75)
    at java.net.AbstractPlainSocketImpl.doConnect(Abstrac tPlainSocketImpl.java:337)
    at java.net.AbstractPlainSocketImpl.connectToAddress( AbstractPlainSocketImpl.java:198)
    at java.net.AbstractPlainSocketImpl.connect(AbstractP lainSocketImpl.java:180)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:157)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava:391)
    at java.net.Socket.connect(Socket.java:579)
    at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.ja va:141)
    at oracle.net.nt.ConnOption.connect(ConnOption.java:1 23)
    at oracle.net.nt.ConnStrategy.execute(ConnStrategy.ja va:337)
    ... 12 more

  6. #6
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,649
    post results from following SQL

    SELECT * FROM V$VERSION;
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    There are no stupid questions, but there are a LOT of Inquisitive Idiots.

  7. #7
    Join Date
    Jan 2012
    Posts
    22
    Quote Originally Posted by anacedent View Post
    post results from following SQL

    SELECT * FROM V$VERSION;
    BANNER
    ----------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 -
    production Pl/sql Release 11.2.0.1.0
    production TNS for 32bit Windows version 11.2.0.1.0
    Production NLSRTL Version 11.2.0.1.0 production

  8. #8
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,649
    Code:
    bcm@bcm-laptop:~$ cat Conn.java
    import java.sql.*;
    class Conn {
      public static void main (String[] args) throws Exception
      {
       Class.forName ("oracle.jdbc.OracleDriver");
    
       Connection conn = DriverManager.getConnection
         ("jdbc:oracle:thin:@//localhost:1521/v112", "scott", "tiger");
                            // @//machineName:port/SID,   userid,  password
       try {
         Statement stmt = conn.createStatement();
         try {
           ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
           try {
             while (rset.next())
               System.out.println (rset.getString(1));   // Print col 1
           } 
           finally {
              try { rset.close(); } catch (Exception ignore) {}
           }
         } 
         finally {
           try { stmt.close(); } catch (Exception ignore) {}
         }
       } 
       finally {
         try { conn.close(); } catch (Exception ignore) {}
       }
      }
    }
    bcm@bcm-laptop:~$ javac Conn.java
    bcm@bcm-laptop:~$ export CLASSPATH=/u01/app/oracle/product/11.2.0/dbhome_1/owb/wf/lib/ojdbc14.jar:.
    bcm@bcm-laptop:~$ java Conn
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE	11.2.0.1.0	Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    bcm@bcm-laptop:~$
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    There are no stupid questions, but there are a LOT of Inquisitive Idiots.

  9. #9
    Join Date
    Jan 2012
    Posts
    22
    same SQLException:

    this code also giving same exception:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •