2010年10月31日日曜日

groovyとsardineでWebDAVサーバ上にファイルをアップロードする

groovyとsardineでWebDAVサーバ上にファイルをアップロードするには、以下のコードを実行します。

import com.googlecode.sardine.*

sardine = SardineFactory.begin('username', 'password')
url = "http://localhost:8080/repository/default/サンプル.JPG"

fis = new FileInputStream("sf2.jpg")
try
{
sardine.put(url, fis)
}
finally
{
fis.close()
}


動作環境
groovy 1.7.4, JDK6 Update21, sardine-129

関連情報

Prudence groovy editionでHello Worldを作成する

Prudence groovy editionでHello Worldを作成するには、以下のコードを実行します。

PRUDENCE_HOME/applications/test/web/dynamicディレクトリに
index.htmlを以下の内容で作成。

<html>
<head><title>prudenceとgroovy</title></head>
<body>
<%
print("prudence groovy editionでhello world" + new Date())
%>
</body>
</html>

※Windowsの場合はUNIX形式ファイルで保存する(改行がLF)。

ブラウザでhttp://localhost:8080/test/にアクセスする。

動作環境
Prudence "Luscious Groovy" Edition R571, JDK6 Update22

関連情報
prudenceのウェブサイト
http://threecrickets.com/prudence/

CentOS5.5にPrudence "Luscious Groovy" Editionをインストールする

CentOS5.5にPrudence "Luscious Groovy" Editionをインストールするには、以下の手順を実行します。

1.以下のサイトからPrudence "Luscious Groovy" Editionをダウンロード
http://threecrickets.com/prudence/download/

2.解凍とパーミッション変更
mkdir /opt/prudence-groovy-R751
mv prudence-groovy-R751.zip /opt/prudence-groovy-R751
unzip prudence-groovy-R751.zip
cd /opt/prudence-groovy-R751/bin
chmod +x run.sh

3.prudence実行
以下のコマンドを実行
cd /opt/prudence-groovy-R751/bin
./run.sh console

ブラウザから以下のアドレスを入力して動作確認
http://yourhost:8080/

※JDKはあらかじめ導入しておくこと。

動作環境
Prudence "Luscious Groovy" Edition R571, JDK6 Update22

関連情報
prudenceのウェブサイト
http://threecrickets.com/prudence/

2010年10月30日土曜日

groovyとhadoopでHDFS上のファイルを列挙する

groovyとhadoopでHDFS上のファイルを列挙するには、以下のコードを実行します。

import org.apache.hadoop.conf.*
import org.apache.hadoop.fs.*

fs = FileSystem.get(
URI.create("hdfs://192.168.1.81:9000/"),
new Configuration())

files = fs.listStatus(new Path("/tmp"))
for( file in files ){
println file.getPath()
}



※Grabを使用しない場合は以下のjarを$GROOVY_HOME/libにコピー
hadoop-common-0.21.0.jar
hadoop-hdfs-0.21.0.jar
log4j-1.2.15.jar

2014/09/14追記:
Grabを使用する場合は、以下のように記述します。
@Grab(group='org.apache.hadoop', module='hadoop-common', version='2.5.0')
@Grab(group='org.apache.hadoop', module='hadoop-hdfs', version='2.5.0')

import org.apache.hadoop.conf.*
import org.apache.hadoop.fs.*

fs = FileSystem.get(
  URI.create("hdfs://localhost:9000/"),
  new Configuration())

files = fs.listStatus(new Path("/tmp"))
for( file in files ){
  println file.getPath()
}

動作環境
groovy 1.7.5, JDK6 Update22, Hadoop 0.21.0
groovy 2.3.6, JDK 7 Update 65, Hadoop 2.5.0

関連情報
CentOS5.5にHadoop0.21.0をインストールする
http://serverarekore.blogspot.com/2010/10/centos55hadoop0210.html

groovyとsardineでWebDAVサーバ上のリソースをダウンロードする

groovyとsardineでWebDAVサーバ上のリソースをダウンロードするには、以下のコードを実行します。

import com.googlecode.sardine.*

sardine = SardineFactory.begin('username', 'password')
url = "http://localhost:8080/repository/default/SF.JPG"
if( sardine.exists(url) ){
is = sardine.getInputStream(url)
fos = new FileOutputStream("download.jpg")
buf = new byte[8192];
int rs = -1;
try
{
while( (rs = is.read(buf)) != -1 ){
fos.write(buf, 0, rs);
}
}
finally
{
fos.close();
is.close();
}
}


動作環境
groovy 1.7.4, JDK6 Update21, sardine-129

関連情報

2010年10月29日金曜日

groovyとsardineでWebDAVサーバ上のリソースが存在するか調べる

groovyとsardineでWebDAVサーバ上のリソースが存在するか調べるには、以下のコードを実行します。

import com.googlecode.sardine.*

sardine = SardineFactory.begin('username', 'password')
url = "http://localhost:8080/repository/default/test.txt"
if( sardine.exists(url) ){
println "存在します"
} else {
println "存在しません"
}


動作環境
groovy 1.7.4, JDK6 Update21, sardine-129

関連情報

2010年10月28日木曜日

groovyとsardineでWebDAVサーバ上のリソースのサイズを取得する

groovyとsardineでWebDAVサーバ上のリソースのサイズを取得するには、以下のコードを実行します。

import com.googlecode.sardine.*

sardine = SardineFactory.begin('username', 'password')
resources = sardine.getResources("http://localhost:8080/repository/default/");
for(resource in resources){
if( !resource.isDirectory() ){
println "name=${resource.nameDecoded}"
println "contentLength=${resource.contentLength}"
println "---"
}
}


動作環境
groovy 1.7.4, JDK6 Update21, sardine-129

関連情報

2010年10月27日水曜日

groovyとsardineでWebDAVサーバ上のフォルダを列挙する

groovyとsardineでWebDAVサーバ上のフォルダを列挙するには、以下のコードを実行します。

import com.googlecode.sardine.*

sardine = SardineFactory.begin('username', 'password')
resources = sardine.getResources("http://localhost:8080/repository/default/");
for(resource in resources){
if( resource.isDirectory() ){
println "name=${resource.nameDecoded}"
}
}


動作環境
groovy 1.7.4, JDK6 Update21, sardine-129

関連情報

2010年10月26日火曜日

groovyとsardineでWebDAVサーバ上のリソースのコンテントタイプを取得する

groovyとsardineでWebDAVサーバ上のリソースのコンテントタイプを取得するには、以下のコードを実行します。

import com.googlecode.sardine.*

sardine = SardineFactory.begin('username', 'password')
resources = sardine.getResources("http://localhost:8080/repository/default/");
for(resource in resources){
println "name=${resource.nameDecoded}:contentType=${resource.getContentType()}"
}


動作環境
groovy 1.7.4, JDK6 Update21, sardine-129

関連情報

2010年10月25日月曜日

groovyとsardineでWebDAVサーバ上のリソースのURLを取得する

groovyとsardineでWebDAVサーバ上のリソースのURLを取得するには、以下のコードを実行します。

import com.googlecode.sardine.*

sardine = SardineFactory.begin('username', 'password')
resources = sardine.getResources("http://localhost:8080/repository/default/");
for(resource in resources){
println "name=${resource.nameDecoded}:url=${resource.getAbsoluteUrl()}"
}


動作環境
groovy 1.7.4, JDK6 Update21, sardine-129

関連情報

2010年10月24日日曜日

groovyとsardineでWebDAVサーバ上のファイル・フォルダの作成日時・最終更新日時を取得する

groovyとsardineでWebDAVサーバ上のファイル・フォルダの作成日時・最終更新日時を取得するには、以下のコードを実行します。

import com.googlecode.sardine.*

sardine = SardineFactory.begin('username', 'password')
resources = sardine.getResources("http://localhost:8080/repository/default/");
for(resource in resources){
println resource.nameDecoded
println "作成日時:" + resource.getCreation()
println "最終変更日時:" + resource.getModified()
}


動作環境
groovy 1.7.4, JDK6 Update21, sardine-129

関連情報

2010年10月23日土曜日

groovyでH2 Databaseのバージョンを取得する

groovyでH2 Databaseのバージョンを取得するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select value from INFORMATION_SCHEMA.SETTINGS where name = 'info.VERSION'
"""

// H2 Databaseのバージョンを取得する
sql.eachRow(query){
println("version of h2 database:${it.value}")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月22日金曜日

groovyとH2 Databaseで指定したPostgreSQLユーザの所有テーブルへのリンクテーブルを作成する

groovyとH2 Databaseで指定したPostgreSQLユーザの所有テーブルへのリンクテーブルを作成するには、以下のコードを実行します。

import groovy.sql.Sql

jdbcUrlPg = "jdbc:postgresql://localhost:5432/yourdb"
jdbcUserPg = "postgres"
jdbcPasswordPg = "postgres"
jdbcDriverPg = "org.postgresql.Driver"
sql = Sql.newInstance(
jdbcUrlPg,
jdbcUserPg,
jdbcPasswordPg,
jdbcDriverPg)

sql2 = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

tablePrefix = "LT_"
query = """
select tablename
from pg_tables
where tableowner = user
and schemaname = 'public'
"""

// 接続ユーザが所有者でpublic schemaのテーブルへのリンクを作成
sql.eachRow(query){
println("creating...:${tablePrefix}${it.tablename}")
sql2.execute("create linked table " +
tablePrefix + it.tablename + "('" +
jdbcDriverPg + "', '" + jdbcUrlPg +
"', '" + jdbcUserPg + "', '" +
jdbcPasswordPg + "', '" + it.tablename + "')"
)
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月21日木曜日

groovyとH2 DatabaseでDBを作成する

groovyとH2 DatabaseでDBを作成するには、以下のコードを実行します。

import groovy.sql.Sql

// サーバモードでDBを作成
sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/C:/share/mydb",
"sa",
"",
"org.h2.Driver")



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月20日水曜日

groovyとH2 Databaseでキャッシュサイズを取得する

groovyとH2 Databaseでキャッシュサイズを取得するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

// キャッシュサイズを取得する
query = """
select value
from
information_schema.settings
where
name = 'CACHE_SIZE'
"""

sql.eachRow(query){
println("cache size:${it.value}(KB)")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月19日火曜日

groovyとH2 Databaseでキャッシュサイズを変更する

groovyとH2 Databaseでキャッシュサイズを変更するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

// キャッシュサイズを64Mに変更する
sql.execute("set cache_size 65536")



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

groovyとsardineでWebDAVサーバ上のファイル・フォルダを列挙する

groovyとsardineでWebDAVサーバ上のファイル・フォルダを列挙するには、以下のコードを実行します。

import com.googlecode.sardine.*

sardine = SardineFactory.begin('username', 'password')
resources = sardine.getResources("http://localhost:8080/repository/default/");
for(resource in resources){
println resource.nameDecoded
}


動作環境
groovy 1.7.4, JDK6 Update21, sardine-129

関連情報

2010年10月18日月曜日

groovyとH2 Databaseでデフォルトスキーマを変更する

groovyとH2 Databaseでデフォルトスキーマを変更するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

// 現在のデフォルトスキーマを変更する
sql.execute("set schema financial")

query = """
select schema() as default_schema
"""

sql.eachRow(query){
println("default schema:${it.default_schema}")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月17日日曜日

groovyとH2 Databaseで現在のデフォルトスキーマを表示する

groovyとH2 Databaseで現在のデフォルトスキーマを表示するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select schema() as default_schema
"""

// 現在のデフォルトスキーマを表示する
sql.eachRow(query){
println("default schema:${it.default_schema}")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月16日土曜日

groovyとH2 Databaseでリンクド・テーブルのみをドロップする

groovyとH2 Databaseでリンクド・テーブルのみをドロップするには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select
table_schema,
table_name
from
information_schema.tables
where
table_type = 'TABLE LINK'
order by table_name
"""

// Linked Tableのみをdropする
sql.eachRow(query){
println("drop:${it.table_schema}.${it.table_name}")
sql.execute("drop table " + it.table_schema +
"." + it.table_name);
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月15日金曜日

groovyとH2 Databaseで指定したOracleユーザの所有テーブルへのリンクテーブルを作成する

groovyとH2 Databaseで指定したOracleユーザの所有テーブルへのリンクテーブルを作成するには、以下のコードを実行します。

import groovy.sql.Sql

jdbcUrlOracle = "jdbc:oracle:thin:@oradb1:1521:orcl"
jdbcUserOracle = "scott"
jdbcPasswordOracle = "tiger"
jdbcDriverOracle = "oracle.jdbc.driver.OracleDriver"
sql = Sql.newInstance(
jdbcUrlOracle,
jdbcUserOracle,
jdbcPasswordOracle,
jdbcDriverOracle)

sql2 = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

tablePrefix = "LT_"

// ユーザテーブルへのリンクテーブルを作成する
sql.eachRow("select table_name from user_tables"){
println("creating...:${tablePrefix}${it.table_name}")
sql2.execute("create linked table " +
tablePrefix + it.table_name + "('" +
jdbcDriverOracle + "', '" + jdbcUrlOracle +
"', '" + jdbcUserOracle + "', '" +
jdbcPasswordOracle + "', '" + it.table_name + "')"
)
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18), Oracle11g R2

2010年10月14日木曜日

groovyとH2 Databaseでユーザを管理者に変更する

groovyとH2 Databaseでユーザを管理者に変更するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

userName = "test1"
query = "alter user " + userName + " admin true"

// ユーザを管理者に変更する
sql.execute(query)


動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月13日水曜日

groovyとH2 Databaseで統計情報を取得する

groovyとH2 Databaseで統計情報を取得するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
ANALYZE SAMPLE_SIZE 20000
"""

// 全てのテーブルの統計を取得する
sql.execute(query)


動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月12日火曜日

groovyとH2 Databaseでクエリーの実行計画を表示する

groovyとH2 Databaseでクエリーの実行計画を表示するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select c1,c2 from test3 where c1 > 5
"""

// クエリーの実行計画を表示する
sql.eachRow("explain plan for " + query){
println("${it.plan}")
}


動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月11日月曜日

groovyとH2 Databaseでデータベースをバックアップする

groovyとH2 Databaseでデータベースをバックアップするには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
backup to 'C:\\share\\h2db\\testdb.zip'
"""

// データベースをバックアップする
sql.execute(query)



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月10日日曜日

groovyとH2 Databaseで現在の接続ユーザを表示する

groovyとH2 Databaseで現在の接続ユーザを表示するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select current_user() as cu
"""

// 現在の接続ユーザを表示する
sql.eachRow(query){
println("current user:${it.cu}")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月9日土曜日

groovyとH2 Databaseでリンクド・テーブルを一覧表示する

groovyとH2 Databaseでリンクド・テーブルを一覧表示するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select
table_schema,
table_name
from
information_schema.tables
where
table_type = 'TABLE LINK'
order by table_name
"""

// Linked Tableを一覧表示する
sql.eachRow(query){
println("table_schema:${it.table_schema}")
println("table_name:${it.table_name}")
println("---")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

関連情報
H2 DatabaseでPostgreSQL Database上のテーブルに対するリンクテーブルを作成する
http://serverarekore.blogspot.com/2010/09/h2-databasepostgresql-database.html

2010年10月8日金曜日

groovyとH2 Databaseでデータベース名とデータベースパスを取得する

groovyとH2 Databaseでデータベース名とデータベースパスを取得するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select database() as dbname,
database_path() as dbpath
"""

// データベース名とデータベースパスを取得する
sql.eachRow(query){
println("database name:${it.dbname}")
println("database path:${it.dbpath}")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月7日木曜日

groovyとH2 Databaseでクエリーの結果をCSVファイルに書き込む

groovyとH2 Databaseでクエリーの結果をCSVファイルに書き込むには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
call csvwrite('C:\\share\\h2db\\output.csv',
'select * from testdata', 'MS932');
"""

// クエリーの結果をCSVファイルに書き込む
sql.execute(query)



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月6日水曜日

groovyとH2 DatabaseでCSVファイルを読み込む

groovyとH2 DatabaseでCSVファイルを読み込むには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select *
from
csvread('C:\\share\\h2db\\testdata.csv','COLUMN1,COLUMN2,COLUMN3')
"""

// CSVファイルを読み込む
sql.eachRow(query){
println("column1:${it.column1}")
println("column2:${it.column2}")
println("column3:${it.column3}")
println("---")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月5日火曜日

groovyとH2 Databaseで空きメモリサイズと使用メモリサイズを取得する

groovyとH2 Databaseで空きメモリサイズと使用メモリサイズを取得するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select memory_free() as free_kb,
memory_used() as used_kb
"""

// 空きメモリサイズと使用メモリサイズを取得する
sql.eachRow(query){
println("Free Memory:${it.free_kb}(KB)")
println("Used Memory:${it.used_kb}(KB)")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月4日月曜日

groovyとH2 DatabaseでセッションIDを取得する

groovyとH2 DatabaseでセッションIDを取得するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select session_id() as sid
"""

// Session IDを取得する
sql.eachRow(query){
println("session_id:${it.sid}")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月3日日曜日

groovyとH2 Databaseでファンクションエイリアスを一覧表示する

groovyとH2 Databaseでファンクションエイリアスを一覧表示するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select
alias_schema,
alias_name,
max(java_class) as jc,
max(java_method) as jm
from
information_schema.function_aliases
group by alias_schema, alias_name
order by alias_name
"""

// Function Aliasを一覧表示する
sql.eachRow(query){
println("alias_schema:${it.alias_schema}")
println("alias_name:${it.alias_name}")
println("java_class:${it.jc}")
println("java_method:${it.jm}")
println("-----")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月2日土曜日

groovyとH2 Databaseでセッションを一覧表示する

groovyとH2 Databaseでセッションを一覧表示するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select
id,
user_name,
session_start,
statement,
statement_start
from
information_schema.sessions
order by session_start
"""

// Sessionを一覧表示する
sql.eachRow(query){
println("id:${it.id}")
println("user_name:${it.user_name}")
println("session_start:${it.session_start}")
println("statement:${it.statement}")
println("statement_start:${it.statement_start}")
println("-----")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)

2010年10月1日金曜日

groovyとH2 Databaseで権限を一覧表示する

groovyとH2 Databaseで権限を一覧表示するには、以下のコードを実行します。

import groovy.sql.Sql

sql = Sql.newInstance(
"jdbc:h2:tcp://localhost/~/test",
"sa",
"",
"org.h2.Driver")

query = """
select
grantee,
granteetype,
grantedrole,
rights,
table_schema,
table_name
from
information_schema.rights
order by grantee, granteetype, grantedrole, rights, table_name
"""

// 権限を一覧表示する
sql.eachRow(query){
println("grantee:${it.grantee}")
println("granteetype:${it.granteetype}")
println("grantedrole:${it.grantedrole}")
println("rights:${it.rights}")
println("table_schema:${it.table_schema}")
println("table_name:${it.table_name}")
println("-----")
}



動作環境
groovy 1.7.4, JDK6 Update 21, H2 Database 1.2.143 (2010-09-18)