Name: sdR10048 Date: 02/17/2004
Filed By : SPB JCK team (###@###.###)
JCK : 1.5
Platform[s] : Solaris
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test:
api/javax_sql/rowset/BaseRowSet/index.html#Options3[BaseRowSet0006]
Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
public void setRef(int parameterIndex, Ref x) throws SQLException
Sets the designated parameter to the given Ref object in the Java programming language.
The driver converts this to an SQL REF value when it sends it to the database.
The parameter value set by this method is stored internally and will be supplied as the
appropriate parameter in this RowSet object's command when the method execute is
called. Methods such as execute and populate must be provided in any class that
extends this class and implements one or more of the standard JSR-114 RowSet
interfaces.
NOTE: JdbcRowSet does not require the populate method as it is undefined in this class.
After this method has been called, a call to the method getParams will return an object
array of the current command parameters, which will include the Ref object set for
placeholder parameter number parameterIndex. Note that because the numbering of
elements in an array starts at zero, the array element that corresponds to placeholder
parameter number parameterIndex is element number parameterIndex -1.
Parameters:
parameterIndex - the ordinal number of the placeholder parameter in this RowSet
object's command that is to be set. The first parameter is 1, the second is 2, and so
on; must be 1 or greater
x - a Ref object representing an SQL REF value
Throws:
SQLException - if an error occurs or the parameter index is out of bounds
...
---------- end-of-excerpt ---------------
Problem description
===================
The designated method throws undeclared NullPointerException in case
Ref input parameter returns null baseTypeName. See demo.
Minimized test:
===============
------- J.java -------
import javax.sql.rowset.serial.*;
import javax.sql.rowset.*;
import java.sql.*;
import java.util.*;
public class J {
public static void main(String[] args) {
MyRef ref = new MyRef();
MyBaseRowSet rowset = new MyBaseRowSet();
try {
rowset.setRef(1, ref);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
class MyBaseRowSet extends BaseRowSet {
public MyBaseRowSet() {
super();
initParams();
}
}
class MyRef implements Ref {
public String getBaseTypeName()
throws SQLException {
return null;
}
public Object getObject(Map map)
throws SQLException {
return null;
}
public Object getObject()
throws SQLException {
return null;
}
public void setObject(Object value)
throws SQLException {
}
}
------- end-of-J.java -------
Minimized test output:
======================
# dsv@happy ~/tmp
# java -showversion J
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b37)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b37, mixed mode)
Exception in thread "main" java.lang.NullPointerException
at java.lang.String.<init>(String.java:151)
at javax.sql.rowset.serial.SerialRef.<init>(SerialRef.java:42)
at javax.sql.rowset.BaseRowSet.setRef(BaseRowSet.java:2650)
at J.main(J.java:11)
JCK test source location:
==========================
/java/re/jck/1.5/promoted/latest/JCK-runtime-15/tests
======================================================================
Name: sdR10048 Date: 02/17/2004
BaseRowSet.setArray(int, Array) has the same problem if
array.getArray() returns null. Corresponding failing tests:
api/javax_sql/rowset/BaseRowSet/index.html#Params1[BaseRowSet0007]
api/javax_sql/rowset/BaseRowSet/index.html#Params1[BaseRowSet0008]
======================================================================
Name: sdR10048 Date: 02/17/2004
BaseRowSet.setClob(int, Clob) has the same problem if
clob.getCharacterStream() returns null. Corresponding failing test:
api/javax_sql/rowset/BaseRowSet/index.html#Params2[BaseRowSet0025]
======================================================================