Description:
I am encountering a repeatable bug on the 5.1.5 MySQL driver using JDBC. It involves a call to getTimestamp() after a call to relative(), where a valid timestamp in the database cannot be retrieved by the driver, which throws an exception. I have tested this under numerous conditions under Linux and OSX.
The stacktrace is as follows:
java.sql.SQLException: Cannot convert value '2007-04-19 16:08:23' from column 2 to TIMESTAMP.
at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:1298)
at com.mysql.jdbc.ByteArrayRow.getTimestampFast(ByteArrayRow.java:124)
at com.mysql.jdbc.ResultSetImpl.getTimestampInternal(ResultSetImpl.java:6610)
at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:5928)
at SimpleScrollBugScript.main(SimpleScrollBugScript.java:36)
How to repeat:
First, create a test database:
mysql> create database testtime;
mysql> \u testtime
mysql> create table timetable (id bigint(20), timestamp datetime);
mysql> insert into timetable values(1,'2007-04-19 16:08:23');
mysql> insert into timetable values(2,'2008-03-12 15:11:33');
mysql> insert into timetable values(3,'2008-04-11 13:01:34');
Then, compile and run the following code in a simple public static main method:
Connection connection = DriverManager.getConnection( "jdbc:mysql://localhost/testtime?user=root" );
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery( "select * from timetable" );
rs.relative( 1 );
rs.getTimestamp( 2 );