protected void executeSQL ( String sql ) { Connection conn = null ; Statement stmt = null ; if ( useAnt ) { try { AntSqlExec sqlExec = new AntSqlExec ( dataSource , sql , delimiter , delimiterType ) ; sqlExec . execute ( ) ; log . info ( "SQL executed with Ant: " + sql ) ; } catch ( BuildException be ) { throw new RuntimeException ( "Failed to execute SQL with Ant (" + be . getMessage ( ) + "): " + sql , be ) ; } } else { try { conn = dataSource . getConnection ( ) ; stmt = conn . createStatement ( ) ; stmt . execute ( sql ) ; log . info ( "SQL executed: " + sql ) ; } catch ( SQLException sqle ) { throw new RuntimeException ( "Failed to execute SQL (" + sqle . getMessage ( ) + "): " + sql , sqle ) ; } finally { ConnectionUtility . closeConnection ( conn , stmt ) ; } } }
Execute one SQL statement . RuntimeException will be thrown if SQLException was caught .