0

I am using apache dbutils. I have an object with a java.util.Date attribute in it. When I execute the following code, it fails for the sql

select name, startDate from myTable

      try {
        QueryRunner run ;
        run = new QueryRunner();

        ResultSetHandler h = new BeanListHandler(clazz);
        ArrayList<T> result ;
        result = (ArrayList) run.query(connection, sql, h);
        return result;
    } catch (SQLException ex) {
        Logger.getLogger(AbstractDataMapper.class.getName()).log(Level.SEVERE, null, ex);
        throw new AppException("Sql fetch failed for: " + sql,ex);
    }

}

I looked at the code and found out that BeanProcessor, processColumn is going through all the properties with the exception of Date. For Date, it is calling rs.getObject(index). This, acc to my debugger returns string and causes the set to fail. Any ideas?

Change driver? I am using jtds 1.2.5. Is it supposed to return Date for getObject method?

user3586195
  • 498
  • 4
  • 15

1 Answers1

2

I tried changing jtds driver version, it did not work. Once I changed data type from date to datetime, it started working without issues. I have also tried datetime2 to see if it will work. No go... In case anyone runs into this issue... Backend is a SQLServer 2008R2 db.

user3586195
  • 498
  • 4
  • 15