以下是我想用groovyc编译的简单类。它总是给我“multiplecompliationErrorException”。
有人可以帮助我吗?
感谢。
import groovy.sql.Sql
class TestDb{
def sql = Sql.newInstance("jdbc:postgresql://localhost:5432/mydb",
"user", "password", "org.postgresql.Driver")
// delete table if previously created
try { sql.execute("drop table if exists PERSON")
} catch(Exception e){}
// create table sql.execute('''create table PERSON (
id integer not null primary key,
firstname varchar(20),
lastname varchar(20),
location_id integer,
location_name varchar(30) )''')
}
答案 0 :(得分:1)
答案 1 :(得分:0)
@ hvgotcodes is right ...这是一个更正的类文件:
import groovy.sql.Sql
class TestDb{
def sql = Sql.newInstance("jdbc:postgresql://localhost:5432/mydb", "user", "password", "org.postgresql.Driver")
static void main( args ) {
// delete table if previously created
sql.execute("drop table if exists PERSON")
sql.execute( '''create table PERSON (
id integer not null primary key,
firstname varchar(20),
lastname varchar(20),
location_id integer,
location_name varchar(30) )''' )
}
}