Created
July 9, 2015 20:42
-
-
Save dalmat36/13bd24c9199a9b963ac9 to your computer and use it in GitHub Desktop.
Simple SQL Insert / Select with Groovy
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; | |
| import java.sql.Connection | |
| import java.sql.DriverManager; | |
| import java.sql.SQLException; | |
| import java.util.Properties; | |
| class GroovySQLTesting { | |
| static main(args) { | |
| def db = Sql.newInstance("jdbc:sqlserver://localhost;databaseName=MyDB;integratedSecurity=true", '', '', 'com.microsoft.sqlserver.jdbc.SQLServerDriver') | |
| db.execute 'exec proc_InsertNewPerson ?,?,?', ['matt', 30, 16803] | |
| db.execute 'exec proc_InsertNewPerson ?,?,?', ['geoff', null, 16803] | |
| db.execute 'exec proc_InsertNewPerson ?,?,?', ['max', null, 16803] | |
| db.eachRow("select * from Person") { | |
| println(it) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment