[ http://issues.apache.org/jira/browse/DERBY-1197?page=comments#action_12374002 ]
Nishant Saini commented on DERBY-1197: -------------------------------------- Thanks Daniel. I had read complete Derby documentation that comes with Derby download but could not figure out that I can also specify the method signature as well in External Name. I wonder why the FAQ page is not included along with Derby Docs provided in download. You can mark the issue resolved now. > 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
