About Me

Mein Bild
Freelancing software developer / architect, mobile geek. Topics: Software technologies (java, groovy, agile), politics, web, science, green, mobile, android.
Homepage: www.tutaona.com

"The absence of limitations is the enemy of art." - Orson Welles

Donnerstag, 10. Mai 2012

Executing a SQL Script on Startup

import groovy.sql.Sql
import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH

String sqlFilePath = ApplicationHolder.application.parentContext.servletContext.getRealPath("/data/table_dump.sql")
String sqlString = new File(sqlFilePath).text
Sql sql = Sql.newInstance(CH.config.dataSource.url, CH.config.dataSource.username, CH.config.dataSource.password, CH.config.dataSource.driverClassName)
sql.execute(sqlString)

Keine Kommentare:

Kommentar veröffentlichen