Skip to content

Commit

Permalink
IDEMPIERE-5994 Connection leak when using DB.prepareStatement(badSql,…
Browse files Browse the repository at this point in the history
… null) (idempiere#2184)

* IDEMPIERE-5994 Connection leak when using DB.prepareStatement(badSql, null)

* - implement approach suggested by Heng Sin
  • Loading branch information
CarlosRuiz-globalqss authored Jan 15, 2024
1 parent a7ddde5 commit 067d2ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;

import javax.sql.RowSet;
Expand Down Expand Up @@ -95,6 +96,11 @@ protected void init() {
p_stmt = conn.prepareStatement(p_vo.getSql(), p_vo
.getResultSetType(), p_vo.getResultSetConcurrency());
} catch (Exception e) {
try {
this.close();
} catch (SQLException e1) {
// ignore
}
log.log(Level.SEVERE, p_vo.getSql(), e);
throw new DBException(e);
}
Expand Down
2 changes: 1 addition & 1 deletion org.adempiere.base/src/org/compiere/db/StatementProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected void init()
* @throws SQLException
* @see java.sql.Statement#close()
*/
private void close () throws SQLException
protected void close () throws SQLException
{
if (close) return;

Expand Down

0 comments on commit 067d2ea

Please sign in to comment.