db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nishant Saini (JIRA)" <derby-...@db.apache.org>
Subject [jira] Created: (DERBY-1197) Problem while setting NULL in PreparedSattement for java.sql.Types.Integer
Date Mon, 10 Apr 2006 14:16:58 GMT
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  
 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

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:
For more information on JIRA, see:

View raw message