When I execute the following code I receive a Exception when the resultset is empty.
If I remove the function in the order by clause the problem don't occur.
This only happens if the resultset generated is empty.
The program:
package tests;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
*
* @author fh
*/
public class NullPointerExceptionNoData {
public static void main(String[] args) throws Exception {
String connectionUrl;
Connection con;
connectionUrl = "jdbc:dbf:/C:/TEMP/";
Class.forName("com.hxtt.sql.dbf.DBFDriver");
con = DriverManager.getConnection(connectionUrl);
String sqlError =
"SELECT f4 " +
"FROM tablex " +
"WHERE f4 = 'ZZZZZZZZZZZZZZZ' " +
"GROUP BY f4 " +
"ORDER BY count(f4) ";
String sqlOk =
"SELECT f4 " +
"FROM tablex " +
"WHERE f4 = 'ZZZZZZZZZZZZZZZ' " +
"GROUP BY f4 " +
"ORDER BY f4 ";
PreparedStatement ps = con.prepareStatement(sqlOk);
ResultSet resp = ps.executeQuery();
System.out.println("** SQL OK **************");
while (resp.next()) {
System.out.println(resp.getString("f4"));
}
resp.close();
ps = con.prepareStatement(sqlError);
resp = ps.executeQuery();
System.out.println("** SQL Error **************");
while (resp.next()) {
System.out.println(resp.getString("f4"));
}
resp.close();
ps.close();
con.close();
}
}
The Sysout
** SQL OK **************
** SQL Error **************
Exception in thread "main" java.lang.NullPointerException
at com.hxtt.sql.df.a(Unknown Source)
at com.hxtt.sql.df.a(Unknown Source)
at com.hxtt.sql.cx.new(Unknown Source)
at com.hxtt.sql.cx.next(Unknown Source)
at tests.NullPointerExceptionNoData.main(NullPointerExceptionNoData.java:60)
|
|
Fixed. It'll be released in 8 hours. Thanks for your response.
|
I tested and it's ok now.
Thanks
|