OPENJPA-1067. Merely log SQLException from setQueryTimeout for DB2 on Z/OS

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@778852 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Dick 2009-05-26 19:12:40 +00:00
parent 5b53615609
commit 2e9f4187cc
2 changed files with 33 additions and 2 deletions

View File

@ -21,6 +21,7 @@ package org.apache.openjpa.jdbc.sql;
import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Arrays;
@ -324,10 +325,11 @@ public class DB2Dictionary
+ "NAME AS SEQUENCE_NAME FROM SYSIBM.SYSSEQUENCES";
sequenceSchemaSQL = "SCHEMA = ?";
sequenceNameSQL = "NAME = ?";
if (maj == 8)
if (maj == 8) {
// DB2 Z/OS Version 8: no bigint support, hence map Java
// long to decimal
bigintTypeName = "DECIMAL(31,0)";
}
break;
case db2ISeriesV5R3OrEarlier:
case db2ISeriesV5R4OrLater:
@ -885,4 +887,28 @@ public class DB2Dictionary
protected void setDelimitedCase(DatabaseMetaData metaData) {
delimitedCase = SCHEMA_CASE_PRESERVE;
}
/**
* The Type 2 JDBC Driver may throw an SQLException when provided a non-
* zero timeout if we're connected to Z/OS. The SQLException should be
* logged but not thrown.
*/
@Override
public void setQueryTimeout(PreparedStatement stmnt, int timeout)
throws SQLException {
if(isDB2ZOSV8xOrLater()) {
try {
super.setQueryTimeout(stmnt, timeout);
}
catch (SQLException e) {
if (log.isTraceEnabled()) {
log.trace(_loc.get("error-setting-query-timeout", timeout,
e.getMessage()), e);
}
}
}
else {
super.setQueryTimeout(stmnt, timeout);
}
}
}

View File

@ -189,3 +189,8 @@ null-blob-in-not-nullable: Can not set null value on column "{0}" \
because the corresponding field is set to be non-nullable.
invalid-timeout: An invalid timeout of {0} milliseconds was ignored. \
Expected a value that is greater than or equal to zero.
error-setting-query-timeout: A SQLException was thrown when trying to set the \
queryTimeout to {0}. We believe the exception is not fatal and will \
continue processing. If this is a benign error you may disable it entirely \
by setting the supportsQueryTimeout attribute on the DBDictionary to false.\
The exception thrown was {1}.