IDEMPIERE-5994 Connection leak when using DB.prepareStatement(badSql, null) (#2184)
* IDEMPIERE-5994 Connection leak when using DB.prepareStatement(badSql, null) * - implement approach suggested by Heng Sin
This commit is contained in:
parent
0b5c7e2256
commit
c9235a02b4
|
@ -15,6 +15,7 @@ package org.compiere.db;
|
|||
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;
|
||||
|
@ -95,6 +96,11 @@ public class PreparedStatementProxy extends StatementProxy {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ public class StatementProxy implements InvocationHandler {
|
|||
* @throws SQLException
|
||||
* @see java.sql.Statement#close()
|
||||
*/
|
||||
private void close () throws SQLException
|
||||
protected void close () throws SQLException
|
||||
{
|
||||
if (close) return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue