Andrea
2007-02-21 19:58:21 UTC
Ciao a tutti,
Io ho un metodo java (incluso in una classe java) come questo qui sotto:
public static ResultSet eseguiSelect(Connection conn,String query) throws
SQLException
{
LogTrace log = new LogTrace();
log.trace("query : "+query);
Statement stmt = null;
ResultSet rs=null;
try
{
stmt=conn.createStatement();
rs=stmt.executeQuery(query);
}
catch(SQLException sqle)
{
log.trace("SQLException : "+sqle.getMessage());
log.trace("SQLState : "+sqle.getSQLState());
log.trace("VendorError : "+sqle.getErrorCode());
try
{
rs.close();
stmt.close();
}
catch(Exception exception)
{ }
throw sqle;
}
return rs;
}
In questa elaborazione non chiudo "stmt" e "rs" perchè "rs" deve essere
ritornato al chiamante del metodo; ma ciò può portare a problemi? Ossia,
questi statement e resultset non chiusi restano "attivi" con conseguente
progressiva occupazione di memoria ad ogni chiamata?
Grazie sin d'ora per l'aiuto che potrete darmi.
JFM
Io ho un metodo java (incluso in una classe java) come questo qui sotto:
public static ResultSet eseguiSelect(Connection conn,String query) throws
SQLException
{
LogTrace log = new LogTrace();
log.trace("query : "+query);
Statement stmt = null;
ResultSet rs=null;
try
{
stmt=conn.createStatement();
rs=stmt.executeQuery(query);
}
catch(SQLException sqle)
{
log.trace("SQLException : "+sqle.getMessage());
log.trace("SQLState : "+sqle.getSQLState());
log.trace("VendorError : "+sqle.getErrorCode());
try
{
rs.close();
stmt.close();
}
catch(Exception exception)
{ }
throw sqle;
}
return rs;
}
In questa elaborazione non chiudo "stmt" e "rs" perchè "rs" deve essere
ritornato al chiamante del metodo; ma ciò può portare a problemi? Ossia,
questi statement e resultset non chiusi restano "attivi" con conseguente
progressiva occupazione di memoria ad ogni chiamata?
Grazie sin d'ora per l'aiuto che potrete darmi.
JFM