jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes JDBC - Connection Refused Error.  Connecting (trying) to Oracle DB. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC - Connection Refused Error.  Connecting (trying) to Oracle DB." Watch "JDBC - Connection Refused Error.  Connecting (trying) to Oracle DB." New topic

JDBC - Connection Refused Error. Connecting (trying) to Oracle DB.

Rembrandt Reyes

Joined: Feb 18, 2009
Posts: 3
warning: greenhorn = me.

I am getting the following error message in my log file whenever I run my Java app which makes connections to an Oracle DB:

SQLException: Io exception: Connection refused

I am sure the HOST is correct. I have also tried using the server name.

Using google fu, I've found references to needing to use a driver called classes12.jar Although I'm not quite sure what to do with it (I've place it in different locations of the app directory but it didn't do anything)

Let me know what other information I can share to help me solve my problem.

Background info, we've recently changed from using a single node to load balancing 2 nodes. That is when the problem started (and when I inherited this application).
I should also warn that this is my first programming/DB assignment coming from a hardware backround. I miss the warm comforts of my switches and routers....

Thank you in advance.

Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
It is your Oracle JDBC driver.

in your classpath would be a good spot for it.
Rembrandt Reyes

Joined: Feb 18, 2009
Posts: 3
- Thanks for the reply Paul.

I've made sure the classes12.jar is in the ClassPath and it already was.

I also added classes12.jar as a jar to my project and then redeployed the app.

I'm still getting the same errors.

- To make sure I understand this, classes12.jar is an oracle driver or what Java uses to communicate with the oracle database. By placing it in the environment variables, the system knows where to find the said driver (and the file does exist in the location above)

- Do I need to do anything else with the file to get it to "be seen"?

- More info: I've installed tomcat on my machine and deployed the code there. It works. No errors. I didn't have to change anything locally (server and local machine are both using Tomcat 5.5). I'm not sure how my local copy is able to talk to Oracle without the classes12.jar driver?

Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

It might be because of firewall between Appserver and DB. check if you are able to connect to DB server using

" telnet ServerIP 1521 " and see what message you get. If you get the Connection refused error , check the firewall settings
Rembrandt Reyes

Joined: Feb 18, 2009
Posts: 3
Thank you Balu. I am able to telnet ok.

Here are some more information if helpful:

The application that is failing is called AppscopeBATCH. It primarily makes runs several cron jobs that use SQL to update tables/views. It can also run manual jobs so that we don't have to wait for evening.

Another App also on this server called AppscopeReports goes into the tables that AppscopeBATCH writes to and generates reports from them.

At the server, AppscopeBATCH isn't running at all and gives those errors I stated. AppscopeReports will run SOMETIMES. 50% of the time it will give a similar connection refused error. I just hit F5 and it will work.

I am of course able to run AppscopeBATCH successfully 100% on my local machine. I am also able to run AppscopeReports 100% on my local machine.

The Database is using 2 nodes/2 IPs. Locally, I can connect successfully using single node or load balanced dual node. On the server, it fails or is sporadic on either.

I'm sorry this sounds so messy.

Suhas Mohamedali

Joined: Jun 05, 2012
Posts: 29
Please download odbc14.jar (for 1.4 and 1.5) from


Copy it into JBOSS_HOME\server\default\lib.

And try to restart the server again.
I agree. Here's the link: http://aspose.com/file-tools
subject: JDBC - Connection Refused Error. Connecting (trying) to Oracle DB.
It's not a secret anymore!