Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

where to close DBconnection in struts..urgent..please help

Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have, for database transactions in my application.
I am using STRuts1.1, eclipse,j2sdk1.4.2, MySql, Tomcat 5.0
where do I close the database connection ..
Is it in DAO class...inside the methods for the transactions.
1.if I do this...I am getting exception saying connection is closed in daomanager.
2.if I do this in DAOmanager class....not in my application
hangs up after 3 or 4 transactions......

public void addProgramEnroll(Familyclient familyclient) throws DatastoreException{
PreparedStatement pspprogramenrollinfo = null;
try {
if (conn.isClosed()) {
throw new IllegalStateException("error.unexpected");
pspprogramenrollinfo = conn.prepareStatement(SQL_INSERT_PROGRAM);
} catch (SQLException ex) {
} catch (NumberFormatException nfe) {
} finally {
try {
if (pspprogramenrollinfo != null) {
} catch (SQLException e) {
throw new RuntimeException("error.unexpected");


public void addProgramEnroll(ServletContext sc, Familyclient familyclient)
throws DatastoreException {
Connection conn = getConnection(sc);
FamilyclientDao dao = new FamilyclientDao(conn);
}catch (Exception ex){
throw DatastoreException.datastoreError(ex);
}finally {
if (conn != null) {
try {
} catch (SQLException sqle) {
log.error("Exception closing connection", sqle);
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic