db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kathey Marsden (JIRA)" <derby-...@db.apache.org>
Subject [jira] Resolved: (DERBY-1197) Problem while setting NULL in PreparedSattement for java.sql.Types.Integer
Date Thu, 27 Apr 2006 23:53:38 GMT
     [ http://issues.apache.org/jira/browse/DERBY-1197?page=all ]
     
Kathey Marsden resolved DERBY-1197:
-----------------------------------

    Resolution: Invalid

User indicated we could mark this resolved as it was user error but it might be good to open
a doc issue for this.

> Problem while setting NULL in PreparedSattement for java.sql.Types.Integer
> --------------------------------------------------------------------------
>
>          Key: DERBY-1197
>          URL: http://issues.apache.org/jira/browse/DERBY-1197
>      Project: Derby
>         Type: Bug

>   Components: JDBC, SQL
>     Versions: 10.0.2.0
>  Environment: Embedded Database
>     Reporter: Nishant Saini
>     Priority: Critical

>
> I have created a Procedure which accepts 3 integer parameters.
> If I create the procedure specifying Integer as parameter type and create The java method
with parameter type: java.lang.Integer, then Derby is unable to find the method. Therefore
I have created the method with parameter type 'int'
> I need to pass null as a parameter to the function. The exception came is attached with
this bug.
> I am using the code:
>             PreparedStatement ps = con.prepareCall("{call MyProcedure(?,?,?)}");
>             if(param1 != null) {
>                         ps.setInt(1, param1.intValue());
>             }else {
>                         ps.setNull(1, Types.INTEGER);
>             }
>             if(param2 != null) {
>                         ps.setInt(2, param2.intValue());
>             }else {
>                         ps.setNull(2, Types.INTEGER);
>             }
>             if(param3 != null) {
>                         ps.setInt(3, param2.intValue());
>             }else {
>                         ps.setNull(3 Types.INTEGER);
>             }
> The exception comes: 
> Caused by: SQL Exception: A NULL value cannot be passed to a method which takes a parameter
of primitive type 'int'.
> 	at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedCallableStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeQuery(Unknown Source)
> Thanks and regards,
> Nishant Saini

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message