In ant build file:
<Path id = "groovy. classpath">
<Fileset dir = "$ {java. Groovy}/lib">
<Include name = "*. Jar"/>
</Fileset>
<Fileset dir = "$ {java. Groovy}/embeddable">
<Include name = "*. Jar"/>
</Fileset>
<Pathelement location = "$ {Ext. libs. Oracle}/classes12.zip"/>
</Path>
<Taskdef name = "groovy"
Classname = "org. codehaus. Groovy. Ant. Groovy"
Classpathref = "groovy. classpath"/>
<Target name = "export. schema. to. File">
<Groovy src = "scripts/export. DB. Gy">
<Arg line = "$ {dB. url }$ {dB. schema. Owner }$ {dB. schema. Password }$ {filename}"/>
</Groovy>
</Target>
Groovy script:
Import groovy. SQL. SQL
Import oracle. JDBC. oracledriver
Println "DB. url:" + ARGs [0]
Println "DB. schema. ownver:" + ARGs [1]
Println "filename:" + ARGs [3]
SQL = SQL. newinstance (ARGs [0], argS [1],
ARGs [2], "Oracle. JDBC. oracledriver ");
New file (ARGs [3]). Delete ()
New file (ARGs [3]). createnewfile ()
Def writer = new file (ARGs [3]). newwriter ()
SQL. eachrow ("select table_name from user_tables order by table_name ASC", {writer. writeline (it. table_name )});
Writer. Close ();
List A = []
New file (ARGs [3]). eachline {Line-> A. Add (line )}
Println ("Total number of tables:" + A. Size ());