import groovy.sql.Sql sql = Sql.newInstance( "jdbc:mysql://localhost/test?characterEncodint=utf8", "root", "root", "com.mysql.jdbc.Driver") // カラムを一覧表示する table = "test1" query = """ select * from information_schema.columns where table_name = ${table} order by ordinal_position """ println "table_schema, table_name, column_name, " + "column_type, is_nullable" sql.eachRow(query){ println("${it.table_schema}, ${it.table_name}, " + "${it.column_name}, \"${it.column_type}\", " + "${it.is_nullable}") }
動作環境
groovy 1.8.3, JDK6 Update23, mysql 5.1
0 件のコメント:
コメントを投稿