• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 9179
  • Last Modified:

java.sql.SQLException: Io exception: Connection refused(DESCRIPTION

I got the error message below from logs.
java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(ERR=12519)(ERROR_STACK=(ERROR=(CODE=12519)(EMFI=4))))

it says that usually this is because SID is incorrect.
in my case this not the case. usually it works ok but sometimes it won't work.
even though the web application doesn't work oracle client, for example, toad can connect and crud data.

I think this is because of my code below.

unfortunately i don't know how to get connections and release them in j2ee.

any ideas?
articles and books do you have in mind?


jdk 1.4
tomcat 5.0
oracle 9i
windows 2000

public class DBConnectionManager {
  static Connection oConn = null;
  public static synchronized Connection getConnection() {
    oConn = DriverManager.getConnection("jdbc:oracle:thin:@url:1521:sdstock" , "auser", "apassword");
    return oConn;

public class ClientsOfTheConnection{
  private Connection conn;
  public ClientOfTheConnection(){
    conn = DBConnectionManager.getConnection();
  public void dbManupulation(){// CRUD
    pstmt = conn.prepareStatement(sql);
    rs = pstmt.executeQuery();
    //do not close conn.
2 Solutions
Have you tried using the DBCP rather than your own connection manager?

Weiping DuSenior Web DeveloperCommented:
- Your codes look like OK.  If you could connect DB by using TOAD without problem,  verify your code connect string against tnsnames.ora.
- Make sure that you are using correct oracle JDBC driver. (http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now