Search code examples
sqljdbcgroovysqlconnectionkatalon-studio

driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption


I am trying to connect to my companies Microsoft sql via my groovy code. Using this code:

String conn= "jdbc:sqlserver://;servername="+url+";databaseName=central;user=***qa***;password=***mypassword***;"
    def sqlConnection = Sql.newInstance(conn,username,password,"com.microsoft.sqlserver.jdbc.SQLServerDriver")

This results with the error:

mgroovy.lang.MissingPropertyException: No such property: connection for class: sqlKeyWords.checking[0;39m [31m at sqlKeyWords.checking.connectDB(checking.groovy:60)[0;39m [31m at sqlKeyWords.checking.invokeMethod(checking.groovy)[0;39m [31m at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:49)[0;39m [31m at CreateOrg.run(CreateOrg:47)[0;39m [31m at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)[0;39m [31m at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)[0;39m [31m at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:331)[0;39m [31m at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:322)[0;39m [31m at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:301)[0;39m [31m at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:293)[0;39m [31m at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:227)[0;39m [31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)[0;39m [31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)[0;39m [31m at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)[0;39m [31m at TempTestCase1555589132729.run(TempTestCase1555589132729.groovy:21)

This error is not so descriptive, therefore here is an error that I found in the debug:

The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption

I later tried this from http://docs.groovy-lang.org/latest/html/api/groovy/sql/Sql.html:

def db = [url:'jdbc:sqlserver:'+url+':central', user:username, password:password, driver:'com.microsoft.sqlserver.jdbc.SQLServerDriver']
def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)

and this resulted in:

No suitable driver found for jdbc:sqlserver:aaa-sql-qa.database.windows.bbb:dbName

I saw many answers, most of them say to play with the server's firewall, but I am able to connect to the DB via my python code or via the SSMS. Also, I don't have the ability to play with the firewall. I saw to use jTDS in this answer, but I was unable to proceed there with other issues (of course it also didn't connect)


Solution

  • I don't know why but when running debug on the line where I connect to debug gave me this error. This occurred to me in automation tool Katalon (which uses groovy)

    (Of course b/c it was not working I was trying to use debug exactly there)