permaculture playing cards*
The moose likes JDBC and the fly likes Can't connect to Oracle database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can Watch "Can New topic
Author

Can't connect to Oracle database

Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
Hi all, I am having a bit of a problem making a simple database connection. Here is my code:


My original problem was �class not found�, but I moved my ojdbc14.jar file into my apache/tomcat5.5/shared/lib directory. Now I�m getting a �connection refused� error, but I can successfully use the same password and username when logging in through SQL Plus.

Does this have something to do with my tnsnames.ora file?

Did I put the ojdbc14.jar file in the right directory?


-Thanks
[ March 08, 2005: Message edited by: Chris Staten ]
Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
OK, my question as to whether or not the tomcat/shared/lib directory is the right place to put the ojdbc14.jar file has been answered here.

I'll move the .jar file. Now I just need to know why my connection is being refused .
[ March 08, 2005: Message edited by: Chris Staten ]
Phani Kumar
Greenhorn

Joined: Feb 15, 2002
Posts: 22
Have you double checked the database URL that you are using? In your code, this is the only place it can go wrong I guess.
Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
It was in my URL. The URL for the thin driver has a couple of different formats, but the one I'm using is:

*remove the "-" infront of "oracle" and "PORT" in the URL, I was just trying to remove the emotes.

My service name in the URL above was SERVICE.WORLD. This is also how it looked in my tnsnames.ora file. However, I didn't need the .WORLD portion of the SERVICE_NAME. I made the adjustment by changing SERVICE.WORLD to SERVICE (e.g. TESTDATABASE.WORLD became TESTDATABASE) and it now works.

[ March 08, 2005: Message edited by: Chris Staten ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Can't connect to Oracle database
 
Similar Threads
Unable to execute jar file....got following stack trace.
ClassNotFoundException
I can't connect to DB
Cannot open connection issue
Unable to execute jar file....got following stack trace.