You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by ho...@apache.org on 2002/10/10 20:20:57 UTC
cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql QueryTagSupport.java UpdateTagSupport.java
horwat 2002/10/10 11:20:57
Modified: standard/src/org/apache/taglibs/standard/tag/common/sql
QueryTagSupport.java UpdateTagSupport.java
Log:
In order for setNull to be used properly it would need to have the right column type.
According to JDBC 3.0 section 13.2.2.3, a null can be passed to the PreparedStatement.setObject() and the parameter will be set to JDBC NULL properly so the PreparedStatment.setNull() call can be removed.
Bugzilla #13405
Revision Changes Path
1.34 +6 -6 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/QueryTagSupport.java
Index: QueryTagSupport.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/QueryTagSupport.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- QueryTagSupport.java 21 Jun 2002 20:19:33 -0000 1.33
+++ QueryTagSupport.java 10 Oct 2002 18:20:57 -0000 1.34
@@ -319,12 +319,12 @@
{
if (parameters != null) {
for (int i = 0; i < parameters.size(); i++) {
- // The first parameter has index 1
- if (parameters.get(i) != null) {
- ps.setObject(i + 1, parameters.get(i));
- } else {
- ps.setNull(i + 1, java.sql.Types.NULL);
- }
+ /* The first parameter has index 1. If a null
+ * is passed to setObject the parameter will be
+ * set to JDBC null so an explicit call to
+ * ps.setNull is not required.
+ */
+ ps.setObject(i + 1, parameters.get(i));
}
}
}
1.24 +6 -7 jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/UpdateTagSupport.java
Index: UpdateTagSupport.java
===================================================================
RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/UpdateTagSupport.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- UpdateTagSupport.java 21 Jun 2002 20:19:33 -0000 1.23
+++ UpdateTagSupport.java 10 Oct 2002 18:20:57 -0000 1.24
@@ -281,13 +281,12 @@
{
if (parameters != null) {
for (int i = 0; i < parameters.size(); i++) {
- // The first parameter has index 1
- if (parameters.get(i) != null) {
- ps.setObject(i + 1, parameters.get(i));
- } else {
- ps.setNull(i + 1, java.sql.Types.NULL);
- }
-
+ /* The first parameter has index 1. If a null
+ * is passed to setObject the parameter will be
+ * set to JDBC null so an explicit call to
+ * ps.setNull is not required.
+ */
+ ps.setObject(i + 1, parameters.get(i));
}
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql
QueryTagSupport.java UpdateTagSupport.java
Posted by Justyna Horwat <Ju...@Sun.com>.
Yes, this behavior was also specified in the previous JDBC version (JDBC
2.1 sect 9.6). I shouldn't have been so specific in my commit message.
Any JDBC driver that is compliant with the specification will work. If
you find a non-compliant driver you should file a bug against it.
If you do have a buggy driver and can't wait for the fix, one workaround
is to use an SQL DML statement without using <sql:param> to specify the
null value for a column.
Justyna
Wolfgang Röckelein wrote:
> Hi,
>
> horwat@apache.org wrote:
>
>> horwat 2002/10/10 11:20:57
>>
>> Modified: standard/src/org/apache/taglibs/standard/tag/common/sql
>> QueryTagSupport.java UpdateTagSupport.java
>> Log:
>> In order for setNull to be used properly it would need to have the
>> right column type.
>> According to JDBC 3.0 section 13.2.2.3, a null can be passed to
>> the PreparedStatement.setObject() and the parameter will be set to
>> JDBC NULL properly so the PreparedStatment.setNull() call can be
>> removed.
>
>
> Are you sure that this works on previous JDBC versions also or will
> the next JSTL Ref Impl. depend on JDBC 3.0? Are you sure that this
> works with common JDBC drivers? I am asking because in the past I have
> experienced problems in this area.
>
> Greetings,
> Wolfgang
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql
QueryTagSupport.java UpdateTagSupport.java
Posted by Wolfgang Röckelein <wo...@wiwi.uni-regensburg.de>.
Hi,
horwat@apache.org wrote:
> horwat 2002/10/10 11:20:57
>
> Modified: standard/src/org/apache/taglibs/standard/tag/common/sql
> QueryTagSupport.java UpdateTagSupport.java
> Log:
> In order for setNull to be used properly it would need to have the right column type.
>
> According to JDBC 3.0 section 13.2.2.3, a null can be passed to the PreparedStatement.setObject() and the parameter will be set to JDBC NULL properly so the PreparedStatment.setNull() call can be removed.
Are you sure that this works on previous JDBC versions also or will the next
JSTL Ref Impl. depend on JDBC 3.0? Are you sure that this works with common JDBC
drivers? I am asking because in the past I have experienced problems in this area.
Greetings,
Wolfgang
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>