How to execute SQL file that contains more than one SQL statements using gradle


(Surbhi Jain) #1

How can I execute SQL file that contains more than one SQL statements. I tried using following code:
task testSql {
gradle.class.classLoader.addURL(new File(‘BuildOutput/SQL/ojdbc6.jar’).toURI().toURL())
def sql = groovy.sql.Sql.newInstance(JDBCURL, DB_PROP_SCHEMA , DB_PROP_PASSWORD , ‘allowMultiQueries=true’, ‘oracle.jdbc.driver.OracleDriver’)
String sqlFilePath = 'testsql/testsqls.sql’
String sqlString = new File(sqlFilePath).text
sql.execute(sqlString)
sql.close()
}

but it is giving error:SQL command not properly ended


(Stefan Oehme) #2

This is not a Gradle question, you’ll be better off asking on a more generic database or Java programming forum.