Skip to content

Instantly share code, notes, and snippets.

@DerSchimi
Last active April 12, 2017 07:29
Show Gist options
  • Save DerSchimi/a0a420c27d034e43cf52b21d1843f242 to your computer and use it in GitHub Desktop.
Save DerSchimi/a0a420c27d034e43cf52b21d1843f242 to your computer and use it in GitHub Desktop.
groovy jdbc oracle
1. download ojdbc7.jar (http://bugmenot.com/view/oracle.com)
2. script oracle.groovy:
def host = "host"
def port = "1521"
def db = "dbname"
def url = "jdbc:oracle:thin:@"+host+":"+port+":"+db
def username = "username"
def password = "password"
@GrabConfig(systemClassLoader=true)
driver = "oracle.jdbc.driver.OracleDriver"
import groovy.sql.*
sql = Sql.newInstance(url,username,password,driver);
sql.eachRow('''select table_name from all_tables
''', { link ->
println link
})
3. groovy -cp ojdbc7.jar oracle.groovy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment