Pour cela il suffit d'utiliser la classe groovy.sql.Sql.
import groovy.sql.Sql
def sql = Sql.newInstance("jdbc:mysql://localhost:6666/mabd", "user", "pwd", "com.mysql.jdbc.Driver")
sql.execute("create table MATABLE (INDEX VARCHAR(3), INFOS VARCHAR(100))")
sql.execute("insert into MATABLE values ('001','Data1')")
sql.execute("insert into MATABLE values ('002','Data2')")
sql.eachRow("select * from MATABLE") {
println "Mes données = ${it.INDEX}->${it.INFOS}"
}
Aucun commentaire:
Enregistrer un commentaire