Bug #34924 getTimestamp() fails after relative() in JDBC
Submitted: 28 Feb 2008 13:32 Modified: 28 Feb 2008 14:17
Reporter: Craig Raw Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: relative, timestamp

[28 Feb 2008 13:32] Craig Raw
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 );
[28 Feb 2008 13:36] Craig Raw
Simple command line app to reproduce bug

Attachment: RelativeBugScript.java (text/plain), 697 bytes.

[28 Feb 2008 14:17] Mark Matthews
Duplicate of Bug#34762 (which is already fixed).