• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Network adapter could not establish the connection

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

snapshot1.jpg
[Thumbnail for snapshot1.jpg]
snapshot3.jpg
[Thumbnail for snapshot3.jpg]
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there an Oracle (XE) server running on the same machine? Because you're trying to connect to one, but the connection is refused.
 
Tripti Ag
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:1521:orcl
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
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Tripti Ag
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are ojdbc5.jar, ojdbc6.jar and ojdbc7.jar compaible with oracle 9i
 
Tripti Ag
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
[Thumbnail for screen4.png]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Tripti Ag
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic