I'm writing a little import routine to insert measurement data from excel to access. In my excel input file I got values for every hour ignoring time change to daylight saving time, so every date will be exactly 1 hour later than the preceding one. No duplicates, no missing dates.
Now I read the data using poi and then try to batch insert the data to the Access database using a prepared statement. But I always get a General Error when executing the batch. Looking at the database I see all data inserted until "2011.03.27 01:00" but next and last date inserted is "2011.03.27 03:00" with the values corresponding to "2011.03.27 02:00" in my input data.
Somehow when inserting the data the date "2011.03.27 02:00" gets converted to "2011.03.27 03:00" implicitely (no Warnings or Errors) and since my date column is marked as primary key the insert fails when trying to insert the real 3'o'clock data.
Is there any way to prevent this conversion from happening? I know that the date "2011.03.27 02:00" does not exist (or at least equals "2011.03.27 03:00") but just for the consistency of my data I need this date to be inserted properly.
Here's my code:
myDBConn = DriverManager.getConnection("jdbc:odbc:mydb");
state = myDBConn.prepareStatement("Insert into myTable values(?,?,?)");
for(int i=0;i<numberOfObjects;i++){
state.clearBatch();
for(int j=0;j<numberOfHours;j++){
state.setString(1,names[i]);
state.setTimestamp(2,dates[j]);
state.setDouble(3, data[i][j]);
state.addBatch();
}
state.executeBatch();
}
state.close();
myConn.close();
I already made sure that dates[] contains the right dates and has no duplicates. The conversion really seems to happen when executing the batch...