import groovy.sql.Sql
class come {
static main(args) {
def sql = Sql.newInstance("jdbc:mysql://localhost/test", "root","nayeem","com.mysql.jdbc.Driver")
assert(sql)
sql.execute('drop table if exists customers')
sql.execute(
'''create table customers(
CustomerID bigint(20) not null auto_increment,
CustomerName varchar(50) not null,
ContactName varchar(50) not null,
Address varchar(50) not null,
city varchar(25) not null,
PostalCode bigint(20) not null,
Country varchar(20) not null,
primary key(CustomerID))''')
def i=1
def key1= new XmlSlurper().parse('E:/kha.xml')
assert(key1)
//key1.each{println it}
for (p in { vars -> customers
} ){
println 'Hai'
println("->$i")
def CustomerID=p.CustomerID.text();
println("->$CustomerID")
def CustomerName=p.CustomerName.text();
println("->$CustomerName")
def ContactName=p.ContactName.text();
println("->$ContactName")
def Address=p.Address.text();
println("->$Address")
def array=[] as String
def city=p.city.text();
println("->$city")
def PostalCode=p.PostalCode.text();
println("->$PostalCode")
def Country=p.Country.text();
println("->$Country")
def key2="insert into customers values($CustomerID,$CustomerName,$ContactName,$Address,$city,$PostalCode,$Country)"
sql.execute(key2)
i++
}
def list=sql.rows"select * from customers"
println ''
println '------reading data--------'
println list
}
}
我正在获取groovy.lang.MissingPropertyException:没有这样的属性:类的CustomerID:来请给我回复