Created
October 18, 2011 23:02
-
-
Save bigtoast/1297015 to your computer and use it in GitHub Desktop.
groovy sql setup
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.* | |
// jdbc config properties | |
// http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html | |
// make sure your mysql driver is on the classpath | |
def uname = "" | |
def password = "" | |
def genDbName( String name ) { name + "_" + (new Date()).getTime() } | |
def dbname = genDbName("mytest") | |
def host = "localhost" | |
def port = "3306" | |
def sql = Sql.newInstance("jdbc:mysql://${host}:${port}/${dbname}?createDatabaseIfNotExist=true", uname, password, "com.mysql.jdbc.Driver") | |
println sql.firstRow("select 1") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment