aspose file tools*
The moose likes Beginning Java and the fly likes The Network Adapter could not establish the connection in jdbc connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "The Network Adapter could not establish the connection in jdbc connection" Watch "The Network Adapter could not establish the connection in jdbc connection" New topic
Author

The Network Adapter could not establish the connection in jdbc connection

srinivas Doni
Greenhorn

Joined: Jun 02, 2011
Posts: 23
Hi to all,

I am new to java. I am getting error[b]:"The Network Adapter could not establish" [/b]the connection while establishing connection to oracle database.


//code
try {

String jdbcurl = "jdbc:oracle:thin:@localhost:1521:" + "ORCL";

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

Driver d = (Driver) c.newInstance();

Properties p = new Properties();
p.put("user", "scott");
p.put("password", "tiger");

Connection con = d.connect(jdbcurl,p);
System.out.println(con);
} catch (Exception e) {
System.out.println("The exception raised is:" + e);
}


If anybody is familar with this one, can help me to resolve this error.

Advanced thanks to all,


withregards,
srini
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

Are you sure you have an Oracle server running on the same machine, and that Oracle server is listening on port 1521?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
srinivas Doni
Greenhorn

Joined: Jun 02, 2011
Posts: 23
Hi,

Actually I installed VM ware and installed Winows Xp sp2 in that VM ware. later i installed Oracle. it is listening to port 1521 only. but i could not find
where i am getting error.

If anybody know about this problem, can help to me to resolve this error.






Advanced thanks to all
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

So Oracle is listening inside the virtual machine? And you're running this code from the virtual machine? Because even though the virtual machine is running on the same physical hardware as your host operating system, it's not the same logical machine - it has its own IP address, name, etc.
srinivas Doni
Greenhorn

Joined: Jun 02, 2011
Posts: 23
Hi Rob Spoor,

how can i run with localhost. is it not possible?. if not, how can i know whether oracle is listening inside virtual machine or outside.

please let me know how can i resolve this error

Advance thanks to you,



With Regards,
srini
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

Localhost means the logical machine (i.e. Windows installation, Linux installation, etc) where you are currently running on. Oracle will be listening wherever you installed it. You're the only one who knows if that's the virtual machine or its host machine.

If it's in the virtual machine and you're running your Java program in the host machine you can connect by replacing localhost with the IP address or server name of the virtual machine. You'll need to make sure there's no firewall blocking access.
srinivas Doni
Greenhorn

Joined: Jun 02, 2011
Posts: 23
Hi Rob Spoor,

connection established.Actually, it has taken another logical name in VM ware i.e.,(windows 7 & windows XP2 have taken different machine names).

Thanks Rob spoor for resolving this error.


Regards,
srini





Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

You're welcome
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: The Network Adapter could not establish the connection in jdbc connection