OPENJPA-1907 Use java.util.Date to java.sql.Date type mapping with DB2 on z/OS when column information is not available.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.1.x@1050081 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jeremy Bauer 2010-12-16 18:05:59 +00:00
parent 5d946df8b8
commit 1a88e39785

View File

@ -31,6 +31,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.util.Arrays;
import java.util.Date;
import java.util.StringTokenizer;
import org.apache.openjpa.jdbc.identifier.DBIdentifier;
@ -1100,4 +1101,19 @@ public class DB2Dictionary
throws SQLException {
//NO-OP
}
/**
* Set the given date value as a parameter to the statement.
*/
public void setDate(PreparedStatement stmnt, int idx, Date val, Column col)
throws SQLException {
// When column metadata is not available, DB2 on z/OS does not like the value produced
// by the default dictionary - java.util.Date is converted to java.sql.Timestamp.
if (db2ServerType == db2ZOSV8xOrLater) {
if (col == null && val != null && "java.util.Date".equals(val.getClass().getName())) {
setDate(stmnt, idx, new java.sql.Date(val.getTime()), null, col);
return;
}
}
super.setDate(stmnt, idx, val, col);
}
}