javax.sql.DataSource
dataSource ;
java.sql.Connection connection;
java.sql.Statement statement;
java.sqlResultset resultSet;
code..
try
{
connection = dataSource.getConnection();
statement = connection.prepareStatement("SELECT FU FROM BAR");
resultSet = statement.executeQuery();
}
catch (SQLException sqlEx)
{
try
{
resultset.close();
statement.close();
connection.close();
}
catch(java.sql.SQLException excp)
{
log.debug("A SQLException has been produced another Exception on
resultset/statement/connection was produced where the
message="=excp.getMessage());
}
}
catch (Exception ex)
{
try
{
resultset.close();
statement.close();
connection.close();
}
catch(java.sql.SQLException excp)
{
log.debug("A General Exception has been produced another SQLException on
resultset/statement/connection was produced where the
message="=excp.getMessage());
}
}
catch(java.sql.SQLException excp)
{
log.debug("SQLException on resultset/statement/connection close
message="=excp.getMessage());
}
}
finally
{
try
{
resultset.close();
statement.close();
connection.close();
}
catch(java.sql.SQLException excp)
{
log.debug("Exception on resultset/statement/connection close
message="=excp.getMessage());
}
} //end finally..
Martin
______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relates to the official business
of Sender. This transmission is of a confidential nature and Sender does not
endorse distribution to any party other than intended recipient. Sender does
not necessarily endorse content contained within this transmission.
> Date: Sun, 22 Feb 2009 11:25:42 +0100
> From: edoa...@aspix.it
> To: users@tomcat.apache.org
> Subject: How to close open connections after application stop?
>
> Hy,
>
> I have one webapp in Tomcat 6.0.18 with this context:
>
> <Context path="/myApp" docBase="myApp" debug="100" reloadable="true">
> <Resource name="jdbc/myApp" auth="Container"
> type="javax.sql.DataSource"
> maxActive="8" maxIdle="5" maxWait="300"
> username="myApp" password="passwd"
> driverClassName="org.postgresql.Driver"
> url="jdbc:postgresql://127.0.0.1:5432/myApp"
> removeAbandoned="true"
> removeAbandonedTimeout="30"
> logAbandoned="true"
> />
> </Context>
>
> After application stop (using tomcat manager) I'd like to (drastic
> example) rename the db, but I can't do it because there are open
> connections.
>
> There are no other application using myApp db, but with "ps ax" I can see:
>
> 189 ?? Ss 0:02.67 postgres: myApp myApp 127.0.0.1(49162) idle
>
> Is there a way to close the connection without closing Toncat?
>
> thank you
> Edoardo
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
_________________________________________________________________
Windows Live™ Hotmail®…more than just e-mail.
http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_hm_justgotbetter_howitworks_022009