private void bindProcedure ( PreparedStatement stmt , ClassDescriptor cld , Object obj , ProcedureDescriptor proc ) throws SQLException { int valueSub = 0 ; // Figure out if we are using a callable statement. If we are, then we // will need to register one or more output parameters. CallableStatement callable = null ; try { callable = ( CallableStatement ) stmt ; } catch ( Exception e ) { m_log . error ( "Error while bind values for class '" + ( cld != null ? cld . getClassNameOfObject ( ) : null ) + "', using stored procedure: " + proc , e ) ; if ( e instanceof SQLException ) { throw ( SQLException ) e ; } else { throw new PersistenceBrokerException ( "Unexpected error while bind values for class '" + ( cld != null ? cld . getClassNameOfObject ( ) : null ) + "', using stored procedure: " + proc ) ; } } // If we have a return value, then register it. if ( ( proc . hasReturnValue ( ) ) && ( callable != null ) ) { int jdbcType = proc . getReturnValueFieldRef ( ) . getJdbcType ( ) . getType ( ) ; m_platform . setNullForStatement ( stmt , valueSub + 1 , jdbcType ) ; callable . registerOutParameter ( valueSub + 1 , jdbcType ) ; valueSub ++ ; } // Process all of the arguments. Iterator iterator = proc . getArguments ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { ArgumentDescriptor arg = ( ArgumentDescriptor ) iterator . next ( ) ; Object val = arg . getValue ( obj ) ; int jdbcType = arg . getJdbcType ( ) ; setObjectForStatement ( stmt , valueSub + 1 , val , jdbcType ) ; if ( ( arg . getIsReturnedByProcedure ( ) ) && ( callable != null ) ) { callable . registerOutParameter ( valueSub + 1 , jdbcType ) ; } valueSub ++ ; } }
Bind a prepared statment that represents a call to a procedure or user - defined function .