Created
September 24, 2015 20:20
-
-
Save marcelbirkner/a599f965b48a3af619f6 to your computer and use it in GitHub Desktop.
Access MySQL Database
This file contains 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 | |
// MySQL DB Settings | |
def dbSchema = ‘schema’ | |
def dbServer = ‘mysqlserver’ | |
def dbUser = ‘user’ | |
def dbPassword = 'password' | |
def dbDriver = 'com.mysql.jdbc.Driver' | |
def dbUrl = 'jdbc:mysql:@' + dbServer + ':' + dbSchema | |
sql = Sql.newInstance( dbUrl, dbUser, dbPassword, dbDriver ) | |
// Write data | |
sql.execute "INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment