Bug #33162 NullPointerEx instead of SQLEx thrown by ResultSetImpl.getTimestamp()
Submitted: 12 Dec 2007 9:39 Modified: 1 Mar 2008 12:31
Reporter: Lars Beuster Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.0.7/5.1.5 OS:Any
Assigned to: CPU Architecture:Any

[12 Dec 2007 9:39] Lars Beuster
Description:
ResultSet.getTimestamp() throws a NullPointerException instead of SQLException if I call getTimestamp() on an empty ResultSet:

Other calls (e.g. getString()) throw the correct SQLException.

Regards
Lars

How to repeat:
ResultSet rs = statement.executeQuery("select something with no result");
b = rs.next(); //but doesnt't matter if called or not called
rs.getTimestamp(1); // -> NPE, but should be SQLException
[12 Dec 2007 12:36] Tonci Grgin
Hi Lars and thanks for your report. Can you please attach full test case so I can check?
[12 Dec 2007 13:09] Lars Beuster
SQL: create table

Attachment: create_table.sql (text/plain), 38 bytes.

[12 Dec 2007 13:09] Lars Beuster
Java-Code (main class)

Attachment: TimestampTest.java (text/java), 975 bytes.

[12 Dec 2007 13:12] Lars Beuster
I attached the SQL-code to create a test-table and the Java-code to produce the error. You have to change the JDBC-URL in Java Code. The rest should be ok.

Regards
Lars
[12 Dec 2007 14:00] Tonci Grgin
Lars, thank you. JDBC-URL is one of the things I wanted to look into.
[12 Dec 2007 14:37] Tonci Grgin
Test case

Attachment: TestBug33162.java (text/x-java), 1.73 KiB.

[12 Dec 2007 14:40] Tonci Grgin
Lars, verified as described on:
 - MySQL server 5.0.54BK on WinXP Pro SP2 localhost
 - JDK 1.5 and c/J 5.0 latest sources

Comments inside attached test case.
[12 Dec 2007 14:53] Lars Beuster
Perhaps as an additional comment: It doesn't matter if the table has a timestamp column or not. My test case was a little but confusing, but I get the same error if the id-column of the table is a timestamp.

create table test1 (id DATETIME);
[12 Dec 2007 14:55] Tonci Grgin
Lars, I got that and made note inside my test case.

Thanks for your interest in MySQL.
[27 Feb 2008 15:06] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/43066
[27 Feb 2008 17:12] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/43086
[1 Mar 2008 12:31] MC Brown
A note has been added to the 5.1.6 changelog: 

ResultSet.getTimestamp() would throw a NullPointerException instead of a SQLException when called on an empty ResultSet.