- postgresql jdbc driver doesn't implement setQueryTimeout yet
This commit is contained in:
Heng Sin Low 2009-07-14 03:09:53 +00:00
parent 607d1c0a26
commit fab259545c
5 changed files with 34 additions and 12 deletions

View File

@ -284,6 +284,11 @@ public interface AdempiereDatabase
public Convert getConvert();
/**
* @return true if jdbc driver support statement timeout
*/
public boolean isQueryTimeoutSupported();
/**
* Get Data Type
* @param DisplayType display type

View File

@ -1105,5 +1105,9 @@ public class DB_Oracle implements AdempiereDatabase
return true;
}
public boolean isQueryTimeoutSupported() {
return true;
}
} // DB_Oracle

View File

@ -782,7 +782,13 @@ public class DB_PostgreSQL implements AdempiereDatabase
else
return true;
}
public boolean isQueryTimeoutSupported() {
return false;
}
/*
public boolean getSupportAlias()
{

View File

@ -134,7 +134,7 @@ public class MSequence extends X_AD_Sequence
ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
pstmt.setString(1, TableName);
//
if (!USE_PROCEDURE)
if (!USE_PROCEDURE && DB.getDatabase().isQueryTimeoutSupported())
pstmt.setQueryTimeout(QUERY_TIME_OUT);
rs = pstmt.executeQuery();
if (CLogMgt.isLevelFinest())
@ -291,7 +291,10 @@ public class MSequence extends X_AD_Sequence
cstmt.setInt(1, AD_Sequence_ID);
cstmt.setString(2, adempiereSys ? "Y" : "N");
cstmt.registerOutParameter(3, Types.INTEGER);
cstmt.setQueryTimeout(QUERY_TIME_OUT);
if (DB.getDatabase().isQueryTimeoutSupported())
{
cstmt.setQueryTimeout(QUERY_TIME_OUT);
}
cstmt.execute();
retValue = cstmt.getInt(3);
}
@ -330,7 +333,10 @@ public class MSequence extends X_AD_Sequence
cstmt.setInt(2, incrementNo);
cstmt.setString(3, calendarYear);
cstmt.registerOutParameter(4, Types.INTEGER);
cstmt.setQueryTimeout(QUERY_TIME_OUT);
if (DB.getDatabase().isQueryTimeoutSupported())
{
cstmt.setQueryTimeout(QUERY_TIME_OUT);
}
cstmt.execute();
retValue = cstmt.getInt(4);
} catch (Exception e) {
@ -495,7 +501,7 @@ public class MSequence extends X_AD_Sequence
pstmt.setString(3, calendarYear);
//
if (!USE_PROCEDURE)
if (!USE_PROCEDURE && DB.getDatabase().isQueryTimeoutSupported())
pstmt.setQueryTimeout(QUERY_TIME_OUT);
rs = pstmt.executeQuery();
// s_log.fine("AC=" + conn.getAutoCommit() + " -Iso=" + conn.getTransactionIsolation()
@ -779,7 +785,7 @@ public class MSequence extends X_AD_Sequence
pstmt.setString(2, calendarYear);
//
if (!USE_PROCEDURE)
if (!USE_PROCEDURE && DB.getDatabase().isQueryTimeoutSupported())
pstmt.setQueryTimeout(QUERY_TIME_OUT);
rs = pstmt.executeQuery();
// s_log.fine("AC=" + conn.getAutoCommit() + " -Iso=" + conn.getTransactionIsolation()

View File

@ -80,14 +80,14 @@ import org.w3c.dom.Element;
public abstract class PO
implements Serializable, Comparator, Evaluatee
{
private static final String USE_TIMEOUT_FOR_UPDATE = "org.adempiere.po.useTimeoutForUpdate";
private static final int QUERY_TIME_OUT = 10;
/**
*
*/
private static final long serialVersionUID = 1876469108787009999L;
private static final long serialVersionUID = 8413360272600437423L;
private static final String USE_TIMEOUT_FOR_UPDATE = "org.adempiere.po.useTimeoutForUpdate";
private static final int QUERY_TIME_OUT = 10;
/**
* Set Document Value Workflow Manager
@ -2404,7 +2404,8 @@ public abstract class PO
} // saveUpdate
private boolean isUseTimeoutForUpdate() {
return "true".equalsIgnoreCase(System.getProperty(USE_TIMEOUT_FOR_UPDATE, "false"));
return "true".equalsIgnoreCase(System.getProperty(USE_TIMEOUT_FOR_UPDATE, "false"))
&& DB.getDatabase().isQueryTimeoutSupported();
}
/**