尝试使用查询插入一行。
如何通过插入 sql 查询使用 groovy 对目标系统进行协调?
//packages
import java.sql.*;
import groovy.sql.Sql
// class
class test {
//main method
static void main(String[] args) {
//Connection:
//def sql = Sql.newInstance("jdbc:oracle:thin:@localhost:1521:orcl", "hr", "hr",
"oracle.jdbc.pool.OracleDataSource")
def sql = Sql.newInstance("jdbc:oracle:thin:@localhost:1521:orcl(sid)", "hr", "hr")
// insert new employee with Sql.executeInsert
def insertStr =
"""insert into Employee
(COL1, COL2)
values
(COL1_seq.nextval, 'hai')"""
def insertedEmployees = sql.executeInsert(insertStr)
println insertedEmployees.dump()
def insertedEmployeeId = insertedEmployees[0][0].toJdbc()
println "TABLE_NAME ${insertedcol1} added."
}
};
错误:
java.sql.SQLException:在 grov.main(grov.groovy:25) 找不到适合 jdbc:oracle:thin:@localhost:1521:orcl(sid) 的驱动程序