Solved

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

Posted on 2006-11-13
4
8,977 Views
Last Modified: 2011-08-18
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?

thanks.


jdk 1.4
tomcat 5.0
oracle 9i
windows 2000

public class DBConnectionManager {
  static Connection oConn = null;
  public static synchronized Connection getConnection() {
    ...
    ...
    ...
    Class.forName("oracle.jdbc.driver.OracleDriver");
    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();
    rs.close();
    pstmt.close();
    //do not close conn.
    ...
    ...
  }  
}
0
Comment
Question by:iamjhkang
4 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 125 total points
ID: 17936523
Have you tried using the DBCP rather than your own connection manager?

http://tomcat.apache.org/tomcat-5.0-doc/jndi-datasource-examples-howto.html#Oracle%208i%20with%20OCI%20client
0
 
LVL 9

Assisted Solution

by:owenli27
owenli27 earned 125 total points
ID: 17939331
- 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)

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
A Short Story about the Best File Recovery Software – Acronis True Image 2017
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now