You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2007/09/04 18:18:44 UTC
[jira] Created: (DERBY-3046) setObj(int,Object,int) causes NPE if
no parameter markers are present; should generate SQLException as for
setObject(int,Object)
setObj(int,Object,int) causes NPE if no parameter markers are present; should generate SQLException as for setObject(int,Object)
--------------------------------------------------------------------------------------------------------------------------------
Key: DERBY-3046
URL: https://issues.apache.org/jira/browse/DERBY-3046
Project: Derby
Issue Type: Bug
Affects Versions: 10.3.1.4
Reporter: Sebb
Priority: Minor
Change WwdClientExample so that there are no parameters, e.g.
psInsert = conn.prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('?')");
Now change
psInsert.setString(1,answer);
to
psInsert.setObject(1,answer);
and the error is OK:
SQLState: XCL14
Severity: 20000
Message: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
java.sql.SQLException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
[...]
However, using:
psInsert.setObject(1,answer,java.sql.Types.VARCHAR);
causes an NPE:
java.lang.NullPointerException
at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.setObjectX(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.setObject(Unknown Source)
at WwdClientExample.main(WwdClientExample.java:93)
Surely it should behave the same as the previous method call - i.e. return an SQLException?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DERBY-3046) setObj(int,Object,int) causes NPE if
no parameter markers are present; should generate SQLException as for
setObject(int,Object)
Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12536336 ]
Mamta A. Satoor commented on DERBY-3046:
----------------------------------------
Committed fix for this in trunk (revision 586596) with following commit comments. Will merge this into 10.3 codeline soon.
DERBY-3046
This commit fixes the null pointer exception by making sure that we do not try to access the object's elements if the object is null. I have also added a test case for this fix.
Additionally, while working on this, I found that we return different sql state for parameter being out of range for PreparedStatment.setObject and Preparedstatement.setXXX calls in Network Server. I have entered a Jira entry for that issue DERBY-3139.
> setObj(int,Object,int) causes NPE if no parameter markers are present; should generate SQLException as for setObject(int,Object)
> --------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3046
> URL: https://issues.apache.org/jira/browse/DERBY-3046
> Project: Derby
> Issue Type: Bug
> Components: JDBC, Network Client
> Affects Versions: 10.3.1.4
> Reporter: Sebb
> Priority: Minor
>
> Change WwdClientExample so that there are no parameters, e.g.
> psInsert = conn.prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('?')");
> Now change
> psInsert.setString(1,answer);
> to
> psInsert.setObject(1,answer);
> and the error is OK:
> SQLState: XCL14
> Severity: 20000
> Message: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> java.sql.SQLException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> [...]
> However, using:
> psInsert.setObject(1,answer,java.sql.Types.VARCHAR);
> causes an NPE:
> java.lang.NullPointerException
> at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObjectX(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObject(Unknown Source)
> at WwdClientExample.main(WwdClientExample.java:93)
> Surely it should behave the same as the previous method call - i.e. return an SQLException?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (DERBY-3046) setObj(int,Object,int) causes NPE if
no parameter markers are present; should generate SQLException as for
setObject(int,Object)
Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mamta A. Satoor resolved DERBY-3046.
------------------------------------
Resolution: Fixed
Fix Version/s: 10.4.0.0
10.3.1.5
> setObj(int,Object,int) causes NPE if no parameter markers are present; should generate SQLException as for setObject(int,Object)
> --------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3046
> URL: https://issues.apache.org/jira/browse/DERBY-3046
> Project: Derby
> Issue Type: Bug
> Components: JDBC, Network Client
> Affects Versions: 10.3.1.4
> Reporter: Sebb
> Assignee: Mamta A. Satoor
> Priority: Minor
> Fix For: 10.3.1.5, 10.4.0.0
>
>
> Change WwdClientExample so that there are no parameters, e.g.
> psInsert = conn.prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('?')");
> Now change
> psInsert.setString(1,answer);
> to
> psInsert.setObject(1,answer);
> and the error is OK:
> SQLState: XCL14
> Severity: 20000
> Message: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> java.sql.SQLException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> [...]
> However, using:
> psInsert.setObject(1,answer,java.sql.Types.VARCHAR);
> causes an NPE:
> java.lang.NullPointerException
> at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObjectX(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObject(Unknown Source)
> at WwdClientExample.main(WwdClientExample.java:93)
> Surely it should behave the same as the previous method call - i.e. return an SQLException?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DERBY-3046) setObj(int,Object,int) causes NPE if
no parameter markers are present; should generate SQLException as for
setObject(int,Object)
Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12537832 ]
Mamta A. Satoor commented on DERBY-3046:
----------------------------------------
Committed the changes into trunk using revision 588527. The commit comments were as follows
DERBY-3046
This commit will ensure that setObject returns the same exception in both Network Server and Embedded WHEN the
PreparedStatement has no parameters associated with it at all. Without the changes that are going in this commit,
following sql will return different exceptions in Embedded and Network Server (this test case is copied from
derbynet.PrepareStatementTest).
ps = prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('bb')");
ps.setObject(1,"cc",java.sql.Types.VARCHAR);
ps.setObject in Embedded will throw SQL State 07009 whereas in Network Server, it will throw SQL State XCL13.
As part of this commit, in the example case above, we will always throw SQL State 07009 in both Embedded and
Network Server.
> setObj(int,Object,int) causes NPE if no parameter markers are present; should generate SQLException as for setObject(int,Object)
> --------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3046
> URL: https://issues.apache.org/jira/browse/DERBY-3046
> Project: Derby
> Issue Type: Bug
> Components: JDBC, Network Client
> Affects Versions: 10.3.1.4
> Reporter: Sebb
> Assignee: Mamta A. Satoor
> Priority: Minor
> Fix For: 10.3.1.5, 10.4.0.0
>
>
> Change WwdClientExample so that there are no parameters, e.g.
> psInsert = conn.prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('?')");
> Now change
> psInsert.setString(1,answer);
> to
> psInsert.setObject(1,answer);
> and the error is OK:
> SQLState: XCL14
> Severity: 20000
> Message: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> java.sql.SQLException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> [...]
> However, using:
> psInsert.setObject(1,answer,java.sql.Types.VARCHAR);
> causes an NPE:
> java.lang.NullPointerException
> at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObjectX(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObject(Unknown Source)
> at WwdClientExample.main(WwdClientExample.java:93)
> Surely it should behave the same as the previous method call - i.e. return an SQLException?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DERBY-3046) setObj(int,Object,int) causes NPE if
no parameter markers are present; should generate SQLException as for
setObject(int,Object)
Posted by "Daniel John Debrunner (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel John Debrunner updated DERBY-3046:
-----------------------------------------
Component/s: Network Client
JDBC
> setObj(int,Object,int) causes NPE if no parameter markers are present; should generate SQLException as for setObject(int,Object)
> --------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3046
> URL: https://issues.apache.org/jira/browse/DERBY-3046
> Project: Derby
> Issue Type: Bug
> Components: JDBC, Network Client
> Affects Versions: 10.3.1.4
> Reporter: Sebb
> Priority: Minor
>
> Change WwdClientExample so that there are no parameters, e.g.
> psInsert = conn.prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('?')");
> Now change
> psInsert.setString(1,answer);
> to
> psInsert.setObject(1,answer);
> and the error is OK:
> SQLState: XCL14
> Severity: 20000
> Message: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> java.sql.SQLException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> [...]
> However, using:
> psInsert.setObject(1,answer,java.sql.Types.VARCHAR);
> causes an NPE:
> java.lang.NullPointerException
> at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObjectX(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObject(Unknown Source)
> at WwdClientExample.main(WwdClientExample.java:93)
> Surely it should behave the same as the previous method call - i.e. return an SQLException?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Reopened: (DERBY-3046) setObj(int,Object,int) causes NPE if
no parameter markers are present; should generate SQLException as for
setObject(int,Object)
Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mamta A. Satoor reopened DERBY-3046:
------------------------------------
Reopening the issue because I have another small change to make as part of this Jira entry which will ensure that setObject returns the same exception in both Network Server and Embedded WHEN the PreparedStatement has no parameters associated with it at all. Currently, following sql will return different exceptions in Embedded and Network Server (this test case is copied from derbynet.PrepareStatementTest).
ps = prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('bb')");
ps.setObject(1,"cc",java.sql.Types.VARCHAR);
ps.setObject in Embedded will throw SQL State 07009 whereas in Network Server, it will throw SQL State XCL13. As part of the change that I plan to commit, in the example case above, we will always throw SQL State 07009 in both Embedded and Network Server.
> setObj(int,Object,int) causes NPE if no parameter markers are present; should generate SQLException as for setObject(int,Object)
> --------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3046
> URL: https://issues.apache.org/jira/browse/DERBY-3046
> Project: Derby
> Issue Type: Bug
> Components: JDBC, Network Client
> Affects Versions: 10.3.1.4
> Reporter: Sebb
> Assignee: Mamta A. Satoor
> Priority: Minor
> Fix For: 10.3.1.5, 10.4.0.0
>
>
> Change WwdClientExample so that there are no parameters, e.g.
> psInsert = conn.prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('?')");
> Now change
> psInsert.setString(1,answer);
> to
> psInsert.setObject(1,answer);
> and the error is OK:
> SQLState: XCL14
> Severity: 20000
> Message: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> java.sql.SQLException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> [...]
> However, using:
> psInsert.setObject(1,answer,java.sql.Types.VARCHAR);
> causes an NPE:
> java.lang.NullPointerException
> at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObjectX(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObject(Unknown Source)
> at WwdClientExample.main(WwdClientExample.java:93)
> Surely it should behave the same as the previous method call - i.e. return an SQLException?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DERBY-3046) setObj(int,Object,int) causes NPE if
no parameter markers are present; should generate SQLException as for
setObject(int,Object)
Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3046?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12536340 ]
Mamta A. Satoor commented on DERBY-3046:
----------------------------------------
Migrated change into 10.3 codeline with revision 586607. Will go ahead and close this issue,
> setObj(int,Object,int) causes NPE if no parameter markers are present; should generate SQLException as for setObject(int,Object)
> --------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3046
> URL: https://issues.apache.org/jira/browse/DERBY-3046
> Project: Derby
> Issue Type: Bug
> Components: JDBC, Network Client
> Affects Versions: 10.3.1.4
> Reporter: Sebb
> Assignee: Mamta A. Satoor
> Priority: Minor
> Fix For: 10.3.1.5, 10.4.0.0
>
>
> Change WwdClientExample so that there are no parameters, e.g.
> psInsert = conn.prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('?')");
> Now change
> psInsert.setString(1,answer);
> to
> psInsert.setObject(1,answer);
> and the error is OK:
> SQLState: XCL14
> Severity: 20000
> Message: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> java.sql.SQLException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> [...]
> However, using:
> psInsert.setObject(1,answer,java.sql.Types.VARCHAR);
> causes an NPE:
> java.lang.NullPointerException
> at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObjectX(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObject(Unknown Source)
> at WwdClientExample.main(WwdClientExample.java:93)
> Surely it should behave the same as the previous method call - i.e. return an SQLException?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (DERBY-3046) setObj(int,Object,int) causes NPE if
no parameter markers are present; should generate SQLException as for
setObject(int,Object)
Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mamta A. Satoor resolved DERBY-3046.
------------------------------------
Resolution: Fixed
Migrated changes from trunk (revision 588527) into 10.3 (revision 588530).
> setObj(int,Object,int) causes NPE if no parameter markers are present; should generate SQLException as for setObject(int,Object)
> --------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3046
> URL: https://issues.apache.org/jira/browse/DERBY-3046
> Project: Derby
> Issue Type: Bug
> Components: JDBC, Network Client
> Affects Versions: 10.3.1.4
> Reporter: Sebb
> Assignee: Mamta A. Satoor
> Priority: Minor
> Fix For: 10.3.1.5, 10.4.0.0
>
>
> Change WwdClientExample so that there are no parameters, e.g.
> psInsert = conn.prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('?')");
> Now change
> psInsert.setString(1,answer);
> to
> psInsert.setObject(1,answer);
> and the error is OK:
> SQLState: XCL14
> Severity: 20000
> Message: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> java.sql.SQLException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> [...]
> However, using:
> psInsert.setObject(1,answer,java.sql.Types.VARCHAR);
> causes an NPE:
> java.lang.NullPointerException
> at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObjectX(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObject(Unknown Source)
> at WwdClientExample.main(WwdClientExample.java:93)
> Surely it should behave the same as the previous method call - i.e. return an SQLException?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (DERBY-3046) setObj(int,Object,int) causes NPE if
no parameter markers are present; should generate SQLException as for
setObject(int,Object)
Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mamta A. Satoor reassigned DERBY-3046:
--------------------------------------
Assignee: Mamta A. Satoor
> setObj(int,Object,int) causes NPE if no parameter markers are present; should generate SQLException as for setObject(int,Object)
> --------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3046
> URL: https://issues.apache.org/jira/browse/DERBY-3046
> Project: Derby
> Issue Type: Bug
> Components: JDBC, Network Client
> Affects Versions: 10.3.1.4
> Reporter: Sebb
> Assignee: Mamta A. Satoor
> Priority: Minor
>
> Change WwdClientExample so that there are no parameters, e.g.
> psInsert = conn.prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('?')");
> Now change
> psInsert.setString(1,answer);
> to
> psInsert.setObject(1,answer);
> and the error is OK:
> SQLState: XCL14
> Severity: 20000
> Message: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> java.sql.SQLException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> [...]
> However, using:
> psInsert.setObject(1,answer,java.sql.Types.VARCHAR);
> causes an NPE:
> java.lang.NullPointerException
> at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObjectX(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObject(Unknown Source)
> at WwdClientExample.main(WwdClientExample.java:93)
> Surely it should behave the same as the previous method call - i.e. return an SQLException?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (DERBY-3046) setObj(int,Object,int) causes NPE if no
parameter markers are present; should generate SQLException as for
setObject(int,Object)
Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-3046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mamta A. Satoor closed DERBY-3046.
----------------------------------
> setObj(int,Object,int) causes NPE if no parameter markers are present; should generate SQLException as for setObject(int,Object)
> --------------------------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-3046
> URL: https://issues.apache.org/jira/browse/DERBY-3046
> Project: Derby
> Issue Type: Bug
> Components: JDBC, Network Client
> Affects Versions: 10.3.1.4
> Reporter: Sebb
> Assignee: Mamta A. Satoor
> Priority: Minor
> Fix For: 10.3.1.5, 10.4.0.0
>
>
> Change WwdClientExample so that there are no parameters, e.g.
> psInsert = conn.prepareStatement("insert into WISH_LIST(WISH_ITEM) values ('?')");
> Now change
> psInsert.setString(1,answer);
> to
> psInsert.setObject(1,answer);
> and the error is OK:
> SQLState: XCL14
> Severity: 20000
> Message: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> java.sql.SQLException: The column position '1' is out of range. The number of columns for this ResultSet is '0'.
> [...]
> However, using:
> psInsert.setObject(1,answer,java.sql.Types.VARCHAR);
> causes an NPE:
> java.lang.NullPointerException
> at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObjectX(Unknown Source)
> at org.apache.derby.client.am.PreparedStatement.setObject(Unknown Source)
> at WwdClientExample.main(WwdClientExample.java:93)
> Surely it should behave the same as the previous method call - i.e. return an SQLException?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.