Solved

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

Posted on 2006-11-13
4
8,983 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

18 Experts available now in Live!

Get 1:1 Help Now