Created
July 6, 2013 10:03
-
-
Save parj/5939457 to your computer and use it in GitHub Desktop.
Gradle using SQL driver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.sql.Sql | |
repositories { | |
mavenCentral() | |
} | |
configurations { | |
driver | |
} | |
dependencies { | |
driver 'net.sourceforge.jtds:jtds:1.2.7' | |
} | |
URLClassLoader loader = GroovyObject.class.classLoader | |
configurations.driver.each {File file -> | |
loader.addURL(file.toURL()) | |
} | |
task(sql) << { | |
String driverName = 'net.sourceforge.jtds.jdbc.Driver' | |
Class.forName(driverName) | |
def test = Sql.newInstance( 'jdbc:jtds:sybase://serverName/dbName-CLASS;domain=domainName', 'username', | |
'password', driverName ) | |
test.eachRow( 'select * from tableName' ) { println "$it.id -- ${it.firstName} --" } | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment