我尝试使用MAC OS 10.10.5 Yosemite上的以下Groovy代码连接到MySQL数据库
import groovy.sql.Sql
try{
def dbURL = 'jdbc:mysql://localhost:3306/sakila'
def dbUserName = 'root'
def dbPassword = 'Orange@27'
def dbDriver = 'com.mysql.jdbc.Driver'
log.info('Good')
def db = Sql.newInstance(dbURL,dbUserName,dbPassword,dbDriver)
}catch(Exception e){
log.info('DB Error')
log.info(e.getMessage())
}finally{
}
但是当我执行此代码时,我会看到以下消息
Sat Aug 13 15:09:14 EDT 2016:INFO:Good
Sat Aug 13 15:09:14 EDT 2016:INFO:DB Error
Sat Aug 13 15:09:14 EDT 2016:INFO:No suitable driver found for jdbc:mysql://localhost:3306/sakila
我已将groovy-sql-2.1.1.jar
,mysql-connector-java-5.1.39-bin.jar
保留在文件夹位置/Applications/SoapUI-5.2.1/bin/ext/
你能帮我解决一下这个问题吗?
答案 0 :(得分:1)
//Register driver com.eviware.soapui.support.GroovyUtils.registerJdbcDriver( "com.mysql.jdbc.Driver") //Get the sql instance using the connection details. Sql.newInstance(dbURL,dbUserName,dbPassword)