Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save outofcoffee/cac4904f0c1ba560e17b94ff85c150c9 to your computer and use it in GitHub Desktop.
Save outofcoffee/cac4904f0c1ba560e17b94ff85c150c9 to your computer and use it in GitHub Desktop.
Edit your $GROOVY_HOME/conf/groovy-start.conf and add the following line:
load !{user.home}/.groovy/grapes/**.jar
After that your @Grab will work as advertised:
#!/usr/bin/env groovy
@Grab(group='mysql', module='mysql-connector-java', version='5.1.12')
import groovy.sql.Sql
def sql = Sql.newInstance("jdbc:mysql://hostname/database", "username", "password", "com.mysql.jdbc.Driver")
sql.firstRow("select * from users where id=1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment