Skip to content

Instantly share code, notes, and snippets.

@bigtoast
Created October 18, 2011 23:02
Show Gist options
  • Save bigtoast/1297015 to your computer and use it in GitHub Desktop.
Save bigtoast/1297015 to your computer and use it in GitHub Desktop.
groovy sql setup
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