This morning it errored on a different line:
output.write(rs.getDate(2) + " " + timeFormat.format(rs.getTime(2)) + "|");
This is within the following:
while (rs.next()){
try{
output.write(rs.getDate(2) + " " + timeFormat.format(rs.getTime(2)) + "|");
....
}
catch(IOException e){//error handling code}
}
output is:
output = new BufferedWriter(new FileWriter(outFile));
Here is the stack trace:
Exception in thread "main" java.lang.NullPointerException
at com.sybase.jdbc3.timedio.RawDbio.reallyRead(Unknown Source)
at com.sybase.jdbc3.timedio.Dbio.doRead(Unknown Source)
at com.sybase.jdbc3.timedio.InStreamMgr.a(Unknown Source)
at com.sybase.jdbc3.timedio.InStreamMgr.doRead(Unknown Source)
at com.sybase.jdbc3.tds.TdsProtocolContext.getChunk(Unknown Source)
at com.sybase.jdbc3.tds.PduInputFormatter.a(Unknown Source)
at com.sybase.jdbc3.tds.PduInputFormatter.read(Unknown Source)
at com.sybase.jdbc3.tds.TdsInputStream.read(Unknown Source)
at com.sybase.jdbc3.utils.CacheStream.read(Unknown Source)
at com.sybase.jdbc3.tds.TdsInputStream.read(Unknown Source)
at com.sybase.jdbc3.tds.TdsInputStream.readInt(Unknown Source)
at com.sybase.jdbc3.tds.TdsDataObject.readDATETIMN(Unknown Source)
at com.sybase.jdbc3.tds.TdsJdbcInputStream.getDateObject(Unknown Source)
at com.sybase.jdbc3.jdbc.SybResultSet.getDate(Unknown Source)
at <removed>.processResults(ProcessRecords.java:118)
at <removed>.Main.main(Main.java:65)
I just ran the query manually, and the first couple of times it seemed to be timing out, and then after that, it runs really fast. So I think I've got two issues - a null value in one (or more) of the fields that output.write doesn't handle correctly (thanks for pointing that out!), and an issue with the query that is causing the field to be null to begin with (none of these fields should ever be null).