db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Waagan (JIRA)" <j...@apache.org>
Subject [jira] Closed: (DERBY-1197) Problem while setting NULL in PreparedSattement for java.sql.Types.Integer
Date Tue, 14 Aug 2007 12:33:32 GMT

     [ https://issues.apache.org/jira/browse/DERBY-1197?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Kristian Waagan closed DERBY-1197.
----------------------------------


Closing issue. Logged DERBY-3005 for updating/improving the manuals.

> Problem while setting NULL in PreparedSattement for java.sql.Types.Integer
> --------------------------------------------------------------------------
>
>                 Key: DERBY-1197
>                 URL: https://issues.apache.org/jira/browse/DERBY-1197
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, SQL
>    Affects 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.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message