protected void setObject ( PreparedStatement statement , int i , Object value ) throws SQLException { if ( value instanceof InParameter || value instanceof OutParameter ) { if ( value instanceof InParameter ) { InParameter in = ( InParameter ) value ; Object val = in . getValue ( ) ; if ( null == val ) { statement . setNull ( i , in . getType ( ) ) ; } else { statement . setObject ( i , val , in . getType ( ) ) ; } } if ( value instanceof OutParameter ) { try { OutParameter out = ( OutParameter ) value ; ( ( CallableStatement ) statement ) . registerOutParameter ( i , out . getType ( ) ) ; } catch ( ClassCastException e ) { throw new SQLException ( "Cannot register out parameter." ) ; } } } else { try { statement . setObject ( i , value ) ; } catch ( SQLException e ) { if ( value == null ) { SQLException se = new SQLException ( "Your JDBC driver may not support null arguments for setObject. Consider using Groovy's InParameter feature." + ( e . getMessage ( ) == null ? "" : " (CAUSE: " + e . getMessage ( ) + ")" ) ) ; se . setNextException ( e ) ; throw se ; } else { throw e ; } } } }
Strategy method allowing derived classes to handle types differently such as for CLOBs etc .