Reputation: 9417
I am trying to connect to MS Sql 2005 DB from SoapUI using Groovy script.
import groovy.sql.Sql
sql = Sql.newInstance("jdbc:jtds:sqlserver://servername\\inst1/databaseName",
"username", "password", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
Error: No suitable driver found for jdbc:jtds:sqlserver://32esx802\inst1/tlMain
I have tried to use net.sourceforge.jtds.jdbc.Driver
but I still get the same error
What am I doing wrong?
Upvotes: 4
Views: 10760
Reputation: 1
Try Adding the following lines to the beginning of your script.
// Registering JDBC Driver
com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver")
Upvotes: 0
Reputation: 875
I had the same problem and looks like I am getting closed. I did everything as stated above but getting following exception- java.lang.UnsupportedOperationException: Java Runtime Environment (JRE) version 1.6 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0.
Upvotes: 0
Reputation: 9417
Found the answer
first remove "jtds" from the connect string, so the syntax will look like
sql = Sql.newInstance("jdbc:sqlserver://servername\\inst1/databaseName",
"username", "password", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
Once this is fixed another error came up. I got a timeout error. Based on the original post there seems to be some weird conflict between Groovy sql and MS sql. to work around this remove the databaseName and the database reference in the sql statement. So the sql syntax will look like.
import groovy.sql.Sql
sql = Sql.newInstance("jdbc:sqlserver://servername\\inst1",
"username", "password", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
def row = sql.firstRow("select te.tDisplayName from dbName.TableName te where te.Column2=5000006")
log.info(row.tDisplayName);
also if you have error stating that could not find com.microsoft.sqlserver.jdbc.SQLServerDriver
make sure you download sqljdbc.jar
from Microsoft site and place it in C:\Program Files\eviware\soapUI-3.6.1\lib
and restart SoapUI.
Upvotes: 1