From 64d0b1290712dd251a533364b840c32000474485 Mon Sep 17 00:00:00 2001 From: bernd Date: Wed, 25 Jul 2012 23:43:39 +0200 Subject: [PATCH 11/22] DateMapper now calls ResultSet.getTimeStamp() and then ResultSet.getObject() and if that fails ResultSet.getDate() (rather than relying on ResultSet.getObject() returning a java.util.Date) as not all database drivers return the same type when calling getObject() (issue found with SQLite JDBC driver) --- .../net/lemnik/eodsql/impl/DefaultTypeMappers.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/eodsql/src/net/lemnik/eodsql/impl/DefaultTypeMappers.java b/eodsql/src/net/lemnik/eodsql/impl/DefaultTypeMappers.java index 74260ad..e8c21a3 100644 --- a/eodsql/src/net/lemnik/eodsql/impl/DefaultTypeMappers.java +++ b/eodsql/src/net/lemnik/eodsql/impl/DefaultTypeMappers.java @@ -458,7 +458,23 @@ class DefaultTypeMappers { final int column) throws SQLException { - return (Date)results.getObject(column); + try { + return results.getTimestamp(column); + } catch (SQLException sqle) { + try { + final Object obj = results.getObject(column); + if (obj instanceof Long) { + return new Date((Long) obj); + } else { + return (Date) obj; + } + } catch (SQLException ex) + { + return results.getDate(column); + } catch (ClassCastException ex) { + return results.getDate(column); + } + } } public void set( -- 1.7.9.5