List:MySQL and Java« Previous MessageNext Message »
From:Ronald Klop Date:August 4 2009 4:38pm
Subject:bug in driver 5.1.8 NPE in ResultSet.getDate(...)
View as plain text  
Hi,

We found a bug in the 5.1.8 driver.
If you access data after all rows of the resultset are read, it gives a
NullPointerException in stead of a nice exception.

The code below is an example. DB.connect(..) is our own code to connect to a DB simply.

Running the code gives.
Exception in thread "main" java.lang.NullPointerException
 at com.mysql.jdbc.ResultSetImpl.getDate(ResultSetImpl.java:2167)
 at com.mysql.jdbc.ResultSetImpl.getDate(ResultSetImpl.java:2127)
 at Test.main(Test.java:18)


Cheers,

Ronald.

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import nl.base.sql.db.DB;

public class Test {

 public static void main(String[] args) throws SQLException {
  Connection connect = DB.connect("logs");
  Statement stat = connect.createStatement();
  ResultSet rs = stat.executeQuery("SELECT 1 LIMIT 0");
  if (rs.next()) {
  throw new RuntimeException("This should not happen.");
  }
  rs.getDate(1);
 }

}

 
Thread
bug in driver 5.1.8 NPE in ResultSet.getDate(...)Ronald Klop4 Aug