Hi,
I am using Spring Tool Suite with Java1-6, hibernate 3.5.5 and oracle 11g for my application. We decided to switch the database from Oracle to MySQL 5.5.18. I changed the database, changed the settings but when I try to compile my application, I get error in a class file that tries to create a UTC timestamp. Class is like this
Code:
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.TimeZone;
import org.hibernate.type.TimestampType;
public class UtcTimestampType extends TimestampType {
private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
@Override
public Object get(ResultSet rs, String name) throws SQLException {
return rs.getTimestamp(name, Calendar.getInstance(UTC));
}
@Override
public void set(PreparedStatement st, Object value, int index) throws SQLException {
Timestamp ts;
if(value instanceof Timestamp) {
ts = (Timestamp) value;
} else {
ts = new Timestamp(((java.util.Date) value).getTime());
}
st.setTimestamp(index, ts, Calendar.getInstance(UTC));
}
}
When I try to compile it, I get couple errors at set method that
Error 1 : set(PreparedStatement, Object, int) of type UtcTimestampType has the same erasure as set(PreparedStatement, T, int) of type AbstractSingleColumnStandardBasicType<T> but does not override it.
Error 2 : The method set(PreparedStatement, Object, int) of type UtcTimestampType must override or implement a supertype method.
Timestamp class extends AbstractSingleColumnStandardBasicType. So, what is the mistake that I am doing here? I appreciate your help.
Thanks,
Jan.