You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the getMoreResults() Method on a java.sql.Statement instance is called and no result is available, then a NullPointerExceptuion is thrown instead of returning false.
Reproducible: Always
Steps to Reproduce:
Start the monetDB SQL Server with database demo and login user=monetdb, password=monetdb (jdbc driver version = 1.20)
execute the first test in JUnit test class provided under Additional Information
Date: 2011-07-07 19:41:30 +0200
From: Simon Brodt <<simon.brodt>>
(In reply to comment 2)
do you have a stacktrace at hand, perhaps?
I added the following main method to the class:
public static void main(final String[] args) throws Exception{
MonetDB monetDB = new MonetDB();
monetDB.setUp();
monetDB.nullPointerExceptionOnGetMoreResults();
}
The produced Exception has the following stacktrace
Exception in thread "main" java.lang.NullPointerException
at nl.cwi.monetdb.jdbc.MonetStatement.getMoreResults(MonetStatement.java:772)
at nl.cwi.monetdb.jdbc.MonetStatement.getMoreResults(MonetStatement.java:749)
at monetdb.MonetDB.nullPointerExceptionOnGetMoreResults(MonetDB.java:36)
at monetdb.MonetDB.main(MonetDB.java:135)
Yes, thanks. The problem here is that you call getMoreResults() while you didn't ever run any query. The API docs don't give me any hint on to what to do in this case, but it feels like this is more of an error than it is "there are no results" to me.
Comment 15916
Date: 2011-07-08 11:21:19 +0200
From: Simon Brodt <<simon.brodt>>
(In reply to comment 4)
Yes, thanks. The problem here is that you call getMoreResults() while you
didn't ever run any query. The API docs don't give me any hint on to what to
do in this case, but it feels like this is more of an error than it is "there
are no results" to me.
The error also occurs if you execute a statement and then call the method twice.
The JDBC API says that:
There are no more results when the following is true:
// stmt is a Statement object
((stmt.getMoreResults(current) == false) && (stmt.getUpdateCount() == -1))
Returns:
true if the next result is a ResultSet object; false if it is an update count or >>there are no more results<<
If the statement was never executed there just are no more reults, i.e. the Method should return false.
A NullointerExcetion should defnitly be wrong.
One could consider a SQLException but Im quite sure this is not in accordance with the API specification.
The error also occurs if you execute a statement and then call the method
twice.
Odd, this is the primary use-case of this function, and e.g. JdbcClient works that way. Are you calling it unconditional, after the conditional you quoted below evaluated to true?
If the statement was never executed there just are no more reults, i.e. the
Method should return false.
You could consider it that way, yes.
A NullointerExcetion should defnitly be wrong.
Fully agree.
One could consider a SQLException but Im quite sure this is not in accordance
with the API specification.
the API doesn't suggest this is the way to go, indeed
Comment 15919
Date: 2011-07-08 11:34:03 +0200
From: Simon Brodt <<simon.brodt>>
The error also occurs if you execute a statement and then call the method
twice.
Sorry, seems that this is not correct. Thought I had tested this.
Statement: fix getMoreResults() NullPointerException on unitialised Statement
Return false from Statement.getMoreResults() instead of a
NullPointerException when no query has been performed on the Statement
yet, bug #2833
Date: 2011-07-07 15:35:47 +0200
From: Simon Brodt <<simon.brodt>>
To: clients devs <>
Version: 11.3.3 (Apr2011-SP1) [obsolete]
Last updated: 2011-07-29 10:52:47 +0200
Comment 15905
Date: 2011-07-07 15:35:47 +0200
From: Simon Brodt <<simon.brodt>>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
Build Identifier:
When the getMoreResults() Method on a java.sql.Statement instance is called and no result is available, then a NullPointerExceptuion is thrown instead of returning false.
Reproducible: Always
Steps to Reproduce:
Actual Results:
NullPointerException
Expected Results:
false
package monetdb;
import static org.junit.Assert.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class MonetDB {
}
Comment 15906
Date: 2011-07-07 15:37:46 +0200
From: Simon Brodt <<simon.brodt>>
Created attachment 64
JUnit Test for reproducing the bug
Comment 15907
Date: 2011-07-07 15:56:31 +0200
From: @grobian
do you have a stacktrace at hand, perhaps?
Comment 15912
Date: 2011-07-07 19:41:30 +0200
From: Simon Brodt <<simon.brodt>>
(In reply to comment 2)
I added the following main method to the class:
The produced Exception has the following stacktrace
Exception in thread "main" java.lang.NullPointerException
at nl.cwi.monetdb.jdbc.MonetStatement.getMoreResults(MonetStatement.java:772)
at nl.cwi.monetdb.jdbc.MonetStatement.getMoreResults(MonetStatement.java:749)
at monetdb.MonetDB.nullPointerExceptionOnGetMoreResults(MonetDB.java:36)
at monetdb.MonetDB.main(MonetDB.java:135)
Is this what you need?
Comment 15915
Date: 2011-07-08 11:12:45 +0200
From: @grobian
Yes, thanks. The problem here is that you call getMoreResults() while you didn't ever run any query. The API docs don't give me any hint on to what to do in this case, but it feels like this is more of an error than it is "there are no results" to me.
Comment 15916
Date: 2011-07-08 11:21:19 +0200
From: Simon Brodt <<simon.brodt>>
(In reply to comment 4)
The error also occurs if you execute a statement and then call the method twice.
The JDBC API says that:
There are no more results when the following is true:
Returns:
true if the next result is a ResultSet object; false if it is an update count or >>there are no more results<<
If the statement was never executed there just are no more reults, i.e. the Method should return false.
A NullointerExcetion should defnitly be wrong.
One could consider a SQLException but Im quite sure this is not in accordance with the API specification.
Comment 15918
Date: 2011-07-08 11:26:23 +0200
From: @grobian
(In reply to comment 5)
Odd, this is the primary use-case of this function, and e.g. JdbcClient works that way. Are you calling it unconditional, after the conditional you quoted below evaluated to true?
You could consider it that way, yes.
Fully agree.
the API doesn't suggest this is the way to go, indeed
Comment 15919
Date: 2011-07-08 11:34:03 +0200
From: Simon Brodt <<simon.brodt>>
Sorry, seems that this is not correct. Thought I had tested this.
Comment 15920
Date: 2011-07-08 11:47:02 +0200
From: @grobian
I created a testcase here to call getMoreResults() on an empty statement, but it doesn't crash at all here :/
Comment 15921
Date: 2011-07-08 11:49:40 +0200
From: @grobian
Sorry, I can. Logic error here while testing.
Comment 15922
Date: 2011-07-08 11:52:37 +0200
From: @grobian
Changeset bac87d4ed683 made by Fabian Groffen fabian@cwi.nl in the MonetDB repo, refers to this bug.
For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=bac87d4ed683
Changeset description:
Comment 16015
Date: 2011-07-29 10:52:47 +0200
From: @sjoerdmullender
The Apr2011-SP2 bugfix release is out.
The text was updated successfully, but these errors were encountered: