1
我試圖運行一個Groovy腳本來連接到Jenkins內的Microsoft SQL Server並插入新數據。我想使用SQL Server驅動程序,並將驅動程序放在Jenkins \ war \ WEB-INF \ lib中。我得到一個錯誤,當我試圖運行在構建步驟如下代碼 - 執行Groovy腳本:Jenkins使用SQL Server驅動程序時出錯
import groovy.sql.Sql
import com.microsoft.sqlserver.jdbc.SQLServerDriver
class Connection {
def sqlConnection
def route = "xxxx"
def user = "xxxx"
def password = "xxxxx"
def driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
Connection(db){
this.route+=db.toString()
this.sqlConnection = Sql.newInstance(route, user, password, driver)
}
static main(args) {
Connection con = new Connection("nameDataBase")
}
}
的錯誤是:
1 error org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
E:\Jenkins\workspace\pruebaDB\hudson1035758401251924782.groovy: 2:
unable to resolve class com.microsoft.sqlserver.jdbc.SQLServerDriver @ line 2, column 1.
import com.microsoft.sqlserver.jdbc.SQLServerDriver`