File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Network adapter could not establish the connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Network adapter could not establish the connection" Watch "Network adapter could not establish the connection" New topic
Author

Network adapter could not establish the connection

Tripti Ag
Ranch Hand

Joined: Jul 03, 2009
Posts: 35
I am new to JDBC. But after reading some tutorials I have already done Java connectivity with oracle 11 G Express edition successfully. The code is as follows:


Now I want to implement this code in my college lab. In my college, oracle 8i or 9i is installed. When I am implementing this code then I am getting errors. I am attaching the snapshots. Please suggest me steps to rectify the problem. As far as classpath is concerned, I have set to classes.zip file. Even I downloaded the ojdbc6 driver at the same location where classes.zip file resides and changed the path to c:\oracle\product\jdbc\lib\ojdbc.jar;.
Snapshots of the error have been attached in a doc file. Please find the same.



[Thumbnail for snapshot1.jpg]

[Thumbnail for snapshot3.jpg]

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

Is there an Oracle (XE) server running on the same machine? Because you're trying to connect to one, but the connection is refused.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Tripti Ag
Ranch Hand

Joined: Jul 03, 2009
Posts: 35
I opened Tnsnames.ora file
and I found Protocol: TCP
Service name: orcl
host: 198.168.0.6
Port 1521
I changed url to jdbcracle:thin:@198.168.0.6:1521rcl
I also tried with \\198.168.0.6.

In college lab, while connecting to oracle
we use name as scott, password as tiger and host string as 'oracle9i'

Also we are using jdk 1.5/ jdk 1.6/ jdk 1.7 in labs.
Now I searched for classes.jar file and I found that classes108.zip and classes111.zip are available only. Then I downloaded ojdbc6.jar but problem did not resolve
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2415
    
    7

Tripti Ag wrote:
Also we are using jdk 1.5/ jdk 1.6/ jdk 1.7 in labs.
Now I searched for classes.jar file and I found that classes108.zip and classes111.zip are available only. Then I downloaded ojdbc6.jar but problem did not resolve


For the Oracle JDBC jars
classes12.jar is pre-Java 1.4
ojdbc14.jar = Java 1.4
ojdbc5.jar = Java 5
ojdbc6.jar = Java 6
ojdbc7.jar = Java 7 (Oracle 12c)

Do check which Java version the classpath is pointing to. Eg using ojdbc6 with java 5 WILL NOT work.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Tripti Ag
Ranch Hand

Joined: Jul 03, 2009
Posts: 35
Are ojdbc5.jar, ojdbc6.jar and ojdbc7.jar compaible with oracle 9i
Tripti Ag
Ranch Hand

Joined: Jul 03, 2009
Posts: 35
Today I downloaded ojdbc7.jar and put it in jdbc\lib folder and se path accordingly. In lab we are having jdk 1.7 and oracle 9i. Now I am getting another error and I have attached screenshot for the same


[screen4.png]

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41839
    
  63
Please do not post screenshots of error messages - copy the text instead and paste it into the post. That makes it easier to read, and also searchable.

WEB-INF/lib is a place where a servlet container will look for jar files, but not the "javac" command. For compilation, you need to add it to the classpath using the "-cp" option.

If by "and se path" you mean the PATH variable, then that has nothing to do with the CLASSPATH. I generally advise not to use the CLASSPATH variable, and instead to add all libraries via the "-cp" option (or set up an Ant build file for that).


Ping & DNS - my free Android networking tools app
Tripti Ag
Ranch Hand

Joined: Jul 03, 2009
Posts: 35
I am not using servlets. I am developing code on notepad. and by "se path" I mean "set classpath". For screenshots, I tried to paste in the query itself but unable to do it. In later posts, I will keep your suggestion in mind. Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41839
    
  63
Well, in that case the way you're setting the CLASSPATH apparently has a problem. But as I said, I advise against using CLASSPATH, and for using "-cp" anyway.

I tried to paste content in the query itself but unable to do it.

What does that mean? Is the problem copying the message from the DOS prompt? Pasting it into a post here should not be a problem.
Tripti Ag
Ranch Hand

Joined: Jul 03, 2009
Posts: 35
Directory structure is as follows:
c:\oracle\ora81\jdbc\lib\jodbc7.jar

I have set my classpath as follows:
.;c:\oracle\ora81\jdbc\lib\jodbc7.jar

And why -cp is better than classpath option

Thanks for response!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Network adapter could not establish the connection