If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > SqlException : The Network Adapter could not establish connection

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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();
		}

	}
}
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 7,497
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.
Don't say, show. Don't promise, prove.
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
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
SqlException : The Network Adapter could not establish connection-ora-00439.jpg  
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 7,497
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.
Don't say, show. Don't promise, prove.
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #6 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 7,497
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.
Don't say, show. Don't promise, prove.
Reply With Quote
  #7 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #8 (permalink)  
Old
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 7,497
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.
Don't say, show. Don't promise, prove.
Reply With Quote
  #9 (permalink)  
Old
Registered User
 
Join Date: Jan 2012
Posts: 22
same SQLException:

this code also giving same exception:
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On