Forum Discussion

SiKing's avatar
SiKing
Community Expert
14 years ago

No suitable driver found for jdbc:sqlserver

Hi all.
I have struggled through this for two days previously. Now I am at another client, and it seems I am destined to repeat the same mistakes.

I am running SoapUI 3.6.1. I tried both the x32 and x64 versions with the exact same results. When it starts up, it reports:

Thu Jun 30 14:17:45 PDT 2011:INFO:Adding [C:\Program Files (x86)\eviware\soapUI-3.6.1\bin\ext\sqljdbc4.jar] to extensions classpath
...
Thu Jun 30 14:17:47 PDT 2011:INFO:Used java version: 1.6.0_21

Tried both versions from Microsoft for sqljdbc4.jar.

FYI:

echo %JAVA_HOME%
C:\Program Files (x86)\eviware\soapUI-3.6.1\jre


When I execute the following:

import groovy.sql.Sql

def sqlInstance = Sql.newInstance(
"jdbc:microsoft:sqlserver://vsqlgmsdb01:1433;databaseName=PatronExtension;",
"user",
"password",
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
)

I get: "Thu Jun 30 14:18:00 PDT 2011:ERROR:An error occured [No suitable driver found for jdbc:sqlserver://vsqlgmsdb01:1433;databaseName=PatronExtension], see error log for details".
I don't know if the stack trace is helpful to anybody:

Thu Jun 30 15:04:34 PDT 2011:ERROR:java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://vsqlgmsdb01;databaseName=PatronExtension;
java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://vsqlgmsdb01;databaseName=PatronExtension;
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at groovy.sql.Sql.newInstance(Sql.java:273)
at groovy.sql.Sql$newInstance.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:132)
at Script4.run(Script4.groovy:3)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:96)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


After spending a day Googling, I tried all the following with the exact same results:

  1. jdbc:sqlserver: instead of jdbc:microsoft:sqlserver:

  2. not including the driver: com.microsoft.sqlserver.jdbc.SQLServerDriver

  3. removing the default port 1433

  4. server IP instead of hostname

  5. sqljdbc.jar instead of sqljdbc4.jar, and both of them

  6. What did I do wrong?

    TIA for any advice.
      • ShasiSingh's avatar
        ShasiSingh
        Occasional Contributor

        Driver registration can be added either your first groovy teststep ( before you used your database connection ) or Setup script section over testSuite.

         

  • eyes123's avatar
    eyes123
    New Contributor
    Wonderful! Just in case this helps this answer get found by anyone else searching, this also works for the oracle.jdbc.driver.OracleDriver.

    cheers.
    • nrajeshkumar's avatar
      nrajeshkumar
      Occasional Contributor

      Great it worked for me Thanks!

      com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("oracle.jdbc.OracleDriver")

      • NithyaMurugesan's avatar
        NithyaMurugesan
        Frequent Visitor

        I'm facing the same issue. Where do I need to update the below?

        com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("oracle.jdbc.OracleDriver")

  • Finan's avatar
    Finan
    Frequent Contributor
    def jdbc_connection = context.expand( '${#Project#jdbc}' ) //( jdbc:sqlserver://127.0.0.1:1433;databaseName=testdb;user=test;password=test)
    def jdbc_driver = context.expand( '${#Project#jdbc_driver}' ) //(com.microsoft.sqlserver.jdbc.SQLServerDriver)
    sql = Sql.newInstance(jdbc_connection, jdbc_driver)

    Does the trick for me....
  • SiKing's avatar
    SiKing
    Community Expert
    Not working for me. I tried every variation from groovy.codehaus.org, but nothing seems to be working.
    I suspect that there is something wrong with loading the jar, but I am not sure how to prove that, and what to do abotu fixing it.
  • SiKing's avatar
    SiKing
    Community Expert
    Maybe I just proved it. I tried changing my connect string to:

    def sqlInstance = Sql.newInstance(
    "blah.blah.blah",
    "user",
    "password",
    "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    )

    And I still get the exact same error. So something is wrong with loading the driver, but what and how do I fix it?
  • Finan's avatar
    Finan
    Frequent Contributor
    Have you added the .jar to the intalldir/bin/ext?