IDEMPIERE-287 org.postgresql.util.PSQLException: Bad value for type int : 2min

This commit is contained in:
Heng Sin Low 2012-06-01 10:43:47 +08:00
parent e93dee5efc
commit 740243db9b
1 changed files with 21 additions and 1 deletions

View File

@ -939,9 +939,29 @@ public class DB_PostgreSQL implements AdempiereDatabase
try try
{ {
rs = conn.createStatement().executeQuery("select current_setting('statement_timeout')"); rs = conn.createStatement().executeQuery("select current_setting('statement_timeout')");
if (rs.next()) if (rs.next()) {
String setting = rs.getString(1);
if (setting != null) {
if (setting.endsWith("min")) {
setting = setting.substring(0, setting.length() - "min".length());
try {
currentTimeout = Integer.parseInt(setting);
currentTimeout = currentTimeout * 60;
} catch (Exception e) {
log.log(Level.INFO, e.getLocalizedMessage(), e);
}
} else if (setting.endsWith("s")) {
setting = setting.substring(0, setting.length() - "s".length());
try {
currentTimeout = Integer.parseInt(setting);
} catch (Exception e) {
log.log(Level.INFO, e.getLocalizedMessage(), e);
}
}
}
currentTimeout = rs.getInt(1) / 1000; currentTimeout = rs.getInt(1) / 1000;
} }
}
finally finally
{ {
DB.close(rs); DB.close(rs);