private CompiledStatement assignStatementArguments ( CompiledStatement stmt ) throws SQLException { boolean ok = false ; try { if ( limit != null ) { // we use this if SQL statement LIMITs are not supported by this database type stmt . setMaxRows ( limit . intValue ( ) ) ; } // set any arguments if we are logging our object Object [ ] argValues = null ; if ( logger . isLevelEnabled ( Level . TRACE ) && argHolders . length > 0 ) { argValues = new Object [ argHolders . length ] ; } for ( int i = 0 ; i < argHolders . length ; i ++ ) { Object argValue = argHolders [ i ] . getSqlArgValue ( ) ; FieldType fieldType = argFieldTypes [ i ] ; SqlType sqlType ; if ( fieldType == null ) { sqlType = argHolders [ i ] . getSqlType ( ) ; } else { sqlType = fieldType . getSqlType ( ) ; } stmt . setObject ( i , argValue , sqlType ) ; if ( argValues != null ) { argValues [ i ] = argValue ; } } logger . debug ( "prepared statement '{}' with {} args" , statement , argHolders . length ) ; if ( argValues != null ) { // need to do the (Object) cast to force args to be a single object logger . trace ( "prepared statement arguments: {}" , ( Object ) argValues ) ; } ok = true ; return stmt ; } finally { if ( ! ok ) { IOUtils . closeThrowSqlException ( stmt , "statement" ) ; } } }
Assign arguments to the statement .