import com.mysql.jdbc.jdbc2.optional.MysqlDataSource
import com.mysql.jdbc.*
import groovy.sql.*
/* the commented code works fine
MysqlDataSource ds = new MysqlDataSource()
ds.user = 'root'
ds.password = ""
ds.url = 'jdbc:mysql://localhost:3306/test'
Sql sql=Sql.newInstance(ds)
sql.close()
*/
d=Class.forName("com.mysql.jdbc.Driver").newInstance()
println d.class // class com.mysql.jdbc.Driver
Sql sql=Sql.newInstance(
'jdbc:mysql://localhost:3306/test',
'root',
"",
'com.mysql.jdbc.Driver'
)
the code commented works fine and I can get the instance of Driver
But when I use the
Sql sql=Sql.newInstance(
'jdbc:mysql://localhost:3306/test',
'root',
"",
'com.mysql.jdbc.Driver'
)
it throws a exception:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test
I can not fix it ,is there anyboy coming to help me?