Revert "Tell JDBC to use UTC when converting timestamp."
This reverts commit 54afc8490a.
Good lord. Apparently we don't want this. MySQL will _still_ interpret the
timestamp that we send using the connection timezone, which may or may not be
UTC. The _only_ way to ensure sanity is to pin the timezone on the JDBC
connection. Sigh.
I cannot believe that in the year of our lord twenty twenty six, we are
formatting dates and times into strings and sending those to databases.
This commit is contained in:
@@ -8,8 +8,6 @@ package com.samskivert.jdbc.jora;
|
|||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.math.*;
|
import java.math.*;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
class FieldDescriptor
|
class FieldDescriptor
|
||||||
{
|
{
|
||||||
@@ -101,7 +99,7 @@ class FieldDescriptor
|
|||||||
pstmt.setTime(column, (java.sql.Time)field.get(obj));
|
pstmt.setTime(column, (java.sql.Time)field.get(obj));
|
||||||
break;
|
break;
|
||||||
case tTimestamp:
|
case tTimestamp:
|
||||||
pstmt.setTimestamp(column, (java.sql.Timestamp)field.get(obj), UTC_CALENDAR);
|
pstmt.setTimestamp(column, (java.sql.Timestamp)field.get(obj));
|
||||||
break;
|
break;
|
||||||
case tStream:
|
case tStream:
|
||||||
java.io.InputStream in = (java.io.InputStream)field.get(obj);
|
java.io.InputStream in = (java.io.InputStream)field.get(obj);
|
||||||
@@ -327,7 +325,7 @@ class FieldDescriptor
|
|||||||
field.set(obj, result.getTime(column));
|
field.set(obj, result.getTime(column));
|
||||||
break;
|
break;
|
||||||
case tTimestamp:
|
case tTimestamp:
|
||||||
field.set(obj, result.getTimestamp(column, UTC_CALENDAR));
|
field.set(obj, result.getTimestamp(column));
|
||||||
break;
|
break;
|
||||||
case tStream:
|
case tStream:
|
||||||
field.set(obj, result.getBinaryStream(column));
|
field.set(obj, result.getBinaryStream(column));
|
||||||
@@ -419,7 +417,4 @@ class FieldDescriptor
|
|||||||
Types.VARCHAR, // tAsString
|
Types.VARCHAR, // tAsString
|
||||||
Types.LONGVARBINARY // tClosure
|
Types.LONGVARBINARY // tClosure
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A UTC calendar used to ensure timezone-correct Timestamp binding and loading. */
|
|
||||||
private static final Calendar UTC_CALENDAR = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user