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 "Daniel John Debrunner (JIRA)" <de...@db.apache.org> on 2006/04/10 16:31:01 UTC

[jira] Commented: (DERBY-1197) Problem while setting NULL in PreparedSattement for java.sql.Types.Integer

    [ http://issues.apache.org/jira/browse/DERBY-1197?page=comments#action_12373862 ] 

Daniel John Debrunner commented on DERBY-1197:
----------------------------------------------

See this FAQ - http://db.apache.org/derby/faq.html#null_args

You can specifiy the Java signature of the method in the EXTERNAL NAME of the CREATE PROCEDURE, something like

EXTERNAL NAME 'org.mypackage.myclass.mymethod(java.lang.Integer,java.lang.Integer,java.lang.Integer)'

> 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