drizzle-jdbc drops fractions within timestamps of a MySql database. The tables were created to support fractional seconds.
We changed the listed methods as stated below. It worked for us, but we tested it only against MySQL Server (not Drizzle Server):
org.drizzle.jdbc.internal.common.AbstractValueObject:
public Timestamp getTimestamp() throws ParseException {
if (rawBytes == null) {
return null;
}
String rawValue = getString();
SimpleDateFormat sdf;
if (rawValue.length() > 20) {
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
} else if (rawValue.length() >= 19) {
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
} else {
sdf = new SimpleDateFormat("yyyy-MM-dd");
}
sdf.setLenient(false);
final java.util.Date utilTime = sdf.parse(rawValue);
return new Timestamp(utilTime.getTime());
}
org.drizzle.jdbc.internal.common.query.parameters.TimeParameter:
public TimeParameter(final long timestamp) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS");
byteRepresentation = ("'" + sdf.format(new Date(timestamp)) + "'").getBytes();
}
org.drizzle.jdbc.internal.common.query.parameters.TimestampParameter:
public TimestampParameter(final long timestamp) {
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
byteRepresentation = String.valueOf("'" + sdf.format(new Date(timestamp)) + "'").getBytes();
}
public TimestampParameter(final long timestamp, final Calendar cal) {
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
sdf.setCalendar(cal);
byteRepresentation = String.valueOf("'" + sdf.format(new Date(timestamp)) + "'").getBytes();
}
org.drizzle.jdbc.internal.mysql.MySQLValueObject:
@Override
public Time getTime() throws ParseException {
if (getBytes() == null) {
return null;
}
final String rawValue = getString();
final SimpleDateFormat sdf;
if (rawValue.length() > 8) {
sdf = new SimpleDateFormat("HH:mm:ss.SSS");
} else {
sdf = new SimpleDateFormat("HH:mm:ss");
}
final java.util.Date utilTime = sdf.parse(rawValue);
return new Time(utilTime.getTime());
}
drizzle-jdbc drops fractions within timestamps of a MySql database. The tables were created to support fractional seconds.
We changed the listed methods as stated below. It worked for us, but we tested it only against MySQL Server (not Drizzle Server):
org.drizzle.jdbc.internal.common.AbstractValueObject:
org.drizzle.jdbc.internal.common.query.parameters.TimeParameter:
org.drizzle.jdbc.internal.common.query.parameters.TimestampParameter:
org.drizzle.jdbc.internal.mysql.MySQLValueObject: