Menu

#5 getDate fails with Calendar parameter

open
nobody
None
5
2009-11-04
2009-11-04
Anonymous
No

Calling
GregorianCalendar gc = new GregorianCalendar();
test_outlook = rs.getDate(25, gc);
Returns
java.lang.NullPointerException
at java.util.Calendar.setTime(Calendar.java:1032)
at de.simplicit.vjdbc.serial.StreamingResultSet.getDate(StreamingResultSet.java:1287)

Where rs is a ResultSet of a select query.

I've also seen this error
java.sql.SQLException: Can't convert type to Date: class java.lang.String
at de.simplicit.vjdbc.serial.StreamingResultSet.getDate(StreamingResultSet.java:618)
at de.simplicit.vjdbc.serial.StreamingResultSet.getDate(StreamingResultSet.java:1287)

The data itself looks OK but it may be NULL (which should be OK)

Discussion

  • Michael Grenier

    Michael Grenier - 2010-09-09

    In public Date getDate(int columnIndex, Calendar cal) throws SQLException {
    the call to
    cal.setTime(getDate(columnIndex));
    is incorrect as getDate will also decrement columnIndex. I think the correct statement should read
    cal.setTime(getDate(columnIndex + 1));

     
  • Michael Grenier

    Michael Grenier - 2010-09-09

    Note that while my fix should stop the exceptions from being thrown, I don't think simply using a java.util.calendar in this way really does the conversion needed between timezones.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.