From cd4fe5966676605b52cb08d47d922612c0e15ce2 Mon Sep 17 00:00:00 2001 From: bernd Date: Thu, 4 Aug 2011 02:11:37 +0200 Subject: [PATCH 08/16] 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 files changed, 17 insertions(+), 1 deletions(-) diff --git a/eodsql/src/net/lemnik/eodsql/impl/DefaultTypeMappers.java b/eodsql/src/net/lemnik/eodsql/impl/DefaultTypeMappers.java index bde0d21..8073a02 100644 --- a/eodsql/src/net/lemnik/eodsql/impl/DefaultTypeMappers.java +++ b/eodsql/src/net/lemnik/eodsql/impl/DefaultTypeMappers.java @@ -409,7 +409,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.6