SoapUI access MS SQL DB from groovy script

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 was found for jdbc: jtds: sqlserver: // 32esx802 \ inst1 / tlMain

I tried using "net.sourceforge.jtds.jdbc.Driver" but I still get the same error

Please let me know what I am doing wrong.

thanks

+4
source share
3 answers

Found an answer

first remove the "jtds" from the connection string, so the syntax will look like

 sql = Sql.newInstance("jdbc:sqlserver://servername\\inst1/databaseName", "username", "password", "com.microsoft.sqlserver.jdbc.SQLServerDriver") 

Once this was fixed, another error occurred. I have a timeout error. Based on the original post , there seems to be some strange conflict between Groovy sql and MS sql. to get around this, remove the database name and database link in the sql statement. This will look like sql syntax.

 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 an error message that com.microsoft.sqlserver.jdbc.SQLServerDriver could not be found, be sure to download sqljdbc.jar from the Microsoft website and place it in C:\Program Files\eviware\soapUI-3.6.1\lib and restart SoapUI.

+1
source

I had the same problem and it looks like I'm closing. I did everything as above, but getting the following exception - java.lang.UnsupportedOperationException: Java Runtime Environment (JRE) version 1.6 is not supported by this driver. Use the sqljdbc4.jar class library that supports JDBC 4.0.

0
source

Try adding the following lines to the top of the script.

 // Registering JDBC Driver com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver") 
0
source

Source: https://habr.com/ru/post/1336928/


All Articles