private void doExecute ( Connection conn ) throws SQLException { PreparedStatement stmt ; int size ; size = _methods . size ( ) ; if ( size == 0 ) { return ; } stmt = conn . prepareStatement ( _sql ) ; try { m_platform . afterStatementCreate ( stmt ) ; } catch ( PlatformException e ) { if ( e . getCause ( ) instanceof SQLException ) { throw ( SQLException ) e . getCause ( ) ; } else { throw new SQLException ( e . getMessage ( ) ) ; } } try { m_platform . beforeBatch ( stmt ) ; } catch ( PlatformException e ) { if ( e . getCause ( ) instanceof SQLException ) { throw ( SQLException ) e . getCause ( ) ; } else { throw new SQLException ( e . getMessage ( ) ) ; } } try { for ( int i = 0 ; i < size ; i ++ ) { Method method = ( Method ) _methods . get ( i ) ; try { if ( method . equals ( ADD_BATCH ) ) { /** * we invoke on the platform and pass the stmt as an arg. */ m_platform . addBatch ( stmt ) ; } else { method . invoke ( stmt , ( Object [ ] ) _params . get ( i ) ) ; } } catch ( IllegalArgumentException ex ) { StringBuffer buffer = generateExceptionMessage ( i , stmt , ex ) ; throw new SQLException ( buffer . toString ( ) ) ; } catch ( IllegalAccessException ex ) { StringBuffer buffer = generateExceptionMessage ( i , stmt , ex ) ; throw new SQLException ( buffer . toString ( ) ) ; } catch ( InvocationTargetException ex ) { Throwable th = ex . getTargetException ( ) ; if ( th == null ) { th = ex ; } if ( th instanceof SQLException ) { throw ( ( SQLException ) th ) ; } else { throw new SQLException ( th . toString ( ) ) ; } } catch ( PlatformException e ) { throw new SQLException ( e . toString ( ) ) ; } } try { /** * this will call the platform specific call */ m_platform . executeBatch ( stmt ) ; } catch ( PlatformException e ) { if ( e . getCause ( ) instanceof SQLException ) { throw ( SQLException ) e . getCause ( ) ; } else { throw new SQLException ( e . getMessage ( ) ) ; } } } finally { stmt . close ( ) ; _methods . clear ( ) ; _params . clear ( ) ; } }
This method performs database modification at the very and of transaction .