IDEMPIERE-455 Discover and fix FindBugs problems / Pattern: ODR_OPEN_DATABASE_RESOURCE
This commit is contained in:
parent
4eb7477046
commit
4eed3a8640
|
@ -127,6 +127,7 @@ public class MSequence extends X_AD_Sequence
|
|||
}
|
||||
|
||||
Connection conn = null;
|
||||
Statement timeoutStatement = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
for (int i = 0; i < 3; i++)
|
||||
|
@ -145,7 +146,7 @@ public class MSequence extends X_AD_Sequence
|
|||
//postgresql use special syntax instead of the setQueryTimeout method
|
||||
if (DB.isPostgreSQL())
|
||||
{
|
||||
Statement timeoutStatement = conn.createStatement();
|
||||
timeoutStatement = conn.createStatement();
|
||||
timeoutStatement.execute("SET LOCAL statement_timeout TO " + ( QUERY_TIME_OUT * 1000 ));
|
||||
}
|
||||
else if (DB.getDatabase().isQueryTimeoutSupported())
|
||||
|
@ -264,6 +265,12 @@ public class MSequence extends X_AD_Sequence
|
|||
DB.close(rs, pstmt);
|
||||
pstmt = null;
|
||||
rs = null;
|
||||
if (timeoutStatement != null){
|
||||
try {
|
||||
timeoutStatement.close();
|
||||
}catch(Exception e){}
|
||||
timeoutStatement = null;
|
||||
}
|
||||
if (conn != null)
|
||||
{
|
||||
try {
|
||||
|
@ -378,6 +385,7 @@ public class MSequence extends X_AD_Sequence
|
|||
int docOrg_ID = 0;
|
||||
int next = -1;
|
||||
|
||||
Statement timeoutStatement = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
|
@ -430,7 +438,7 @@ public class MSequence extends X_AD_Sequence
|
|||
//postgresql use special syntax instead of the setQueryTimeout method
|
||||
if (DB.isPostgreSQL())
|
||||
{
|
||||
Statement timeoutStatement = conn.createStatement();
|
||||
timeoutStatement = conn.createStatement();
|
||||
timeoutStatement.execute("SET LOCAL statement_timeout TO " + ( QUERY_TIME_OUT * 1000 ));
|
||||
}
|
||||
else if (DB.getDatabase().isQueryTimeoutSupported())
|
||||
|
@ -511,6 +519,10 @@ public class MSequence extends X_AD_Sequence
|
|||
// Finish
|
||||
try
|
||||
{
|
||||
if (timeoutStatement != null) {
|
||||
timeoutStatement.close();
|
||||
timeoutStatement = null;
|
||||
}
|
||||
if (trx == null && conn != null) {
|
||||
conn.close();
|
||||
conn = null;
|
||||
|
|
|
@ -1101,6 +1101,7 @@ public final class DB
|
|||
{
|
||||
if (DB.isPostgreSQL())
|
||||
{
|
||||
Statement timeoutStatement = null;
|
||||
try
|
||||
{
|
||||
Connection conn = cs.getConnection();
|
||||
|
@ -1119,16 +1120,26 @@ public final class DB
|
|||
}
|
||||
finally
|
||||
{
|
||||
if (rs != null)
|
||||
rs.getStatement().close();
|
||||
DB.close(rs);
|
||||
}
|
||||
}
|
||||
Statement timeoutStatement = conn.createStatement();
|
||||
timeoutStatement = conn.createStatement();
|
||||
timeoutStatement.execute("SET LOCAL statement_timeout TO " + ( timeOut * 1000 ));
|
||||
if (log.isLoggable(Level.FINEST))
|
||||
{
|
||||
log.finest("Set statement timeout to " + timeOut);
|
||||
}
|
||||
} catch (SQLException e) {}
|
||||
finally{
|
||||
if (timeoutStatement != null) {
|
||||
try {
|
||||
timeoutStatement.close();
|
||||
} catch (Exception e) {}
|
||||
timeoutStatement = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1150,6 +1161,7 @@ public final class DB
|
|||
{
|
||||
if (DB.isPostgreSQL() && timeOut > 0)
|
||||
{
|
||||
Statement timeoutStatement = null;
|
||||
try {
|
||||
if (autoCommit)
|
||||
{
|
||||
|
@ -1159,7 +1171,7 @@ public final class DB
|
|||
{
|
||||
if (currentTimeout > 0)
|
||||
{
|
||||
Statement timeoutStatement = cs.getConnection().createStatement();
|
||||
timeoutStatement = cs.getConnection().createStatement();
|
||||
timeoutStatement.execute("SET LOCAL statement_timeout TO " + ( currentTimeout * 1000 ));
|
||||
if (log.isLoggable(Level.FINEST))
|
||||
{
|
||||
|
@ -1168,7 +1180,7 @@ public final class DB
|
|||
}
|
||||
else
|
||||
{
|
||||
Statement timeoutStatement = cs.getConnection().createStatement();
|
||||
timeoutStatement = cs.getConnection().createStatement();
|
||||
timeoutStatement.execute("SET LOCAL statement_timeout TO Default");
|
||||
if (log.isLoggable(Level.FINEST))
|
||||
{
|
||||
|
@ -1179,6 +1191,14 @@ public final class DB
|
|||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
finally{
|
||||
if (timeoutStatement != null) {
|
||||
try {
|
||||
timeoutStatement.close();
|
||||
} catch (Exception e) {}
|
||||
timeoutStatement = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
DB.close(cs);
|
||||
}
|
||||
|
|
|
@ -963,6 +963,8 @@ public class DB_PostgreSQL implements AdempiereDatabase
|
|||
}
|
||||
finally
|
||||
{
|
||||
if (rs != null)
|
||||
rs.getStatement().close();
|
||||
DB.close(rs);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue