Created
March 26, 2014 09:23
-
-
Save peysal/9779537 to your computer and use it in GitHub Desktop.
Basic sql query to db using groovy
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 | |
String db_server = "bun" | |
String db_database = "bun" | |
String db_port = "1433" | |
String db_user = "bun" | |
String db_password = "bun" | |
String connectionUrl = "jdbc:sqlserver://" + db_server + ":" + db_port + | |
";database=" + db_database + | |
";user=" + db_user + | |
";password=" + db_password; | |
sql = Sql.newInstance( connectionUrl, "com.microsoft.sqlserver.jdbc.SQLServerDriver") | |
sql.eachRow( 'select top 1 * from Account' ) { println "$it" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment