Forum Discussion

Ram_N's avatar
Ram_N
Contributor
17 years ago

Unable to connect to SQL Server 2005 - with 'Data Source' using JDBC

Unable to connect to SQL Server 2005 DB using feature 'Data Source' using JDBC

I am using 

Driver as : com.microsoft.sqlserver.jdbc.SQLServerDriver 
connection string as: jdbc:sqlserver://systemname;Database=mydbname;Uid=username;Pwd=pwd 

Below is the error message 

Java.lang.Exception: Failed to init connection for drvr [com.microsoft.sqlserver.jdbc.SQLServerDriver ], connectionString [jdbc:sqlserver://systemname;Database=mydbname;Uid=username;Pwd=pwd] 

Earlier I download and I copied 'sqljdbc.jar' in C:\Program Files\eviware\soapUI-Pro-2.0.2\bin\ext 

Please advise...  thank you in advance

17 Replies

  • M McDonald wrote:
    I don't think just dropping the .zip will do it.

    Put the following files in these locations:

    ntlmauth.dll in C:\Program Files\eviware\soapUI-Pro-3.5.1\bin
    jtds-1.2.5.jar in C:\Program Files\eviware\soapUI-Pro-3.5.1\bin\ext

    Register the driver properties in soapUI preferences (I called it "JTDS Trusted"); replace yourdomain with your domain:

    jdbc:jtds:sqlserver://<HOST:127.0.0.1>:<PORT:1433>/<DB>;domain=yourdomain;trusted_connection=yes

    Does this help?



    Hi,

    I have tried the above described method but still I'm unable to connect to database.

    string used : jdbc:jtds:sqlserver://<HOST:given my DB ip address >:<PORT:1433>/Quality;domain=PROD;trusted_connection=yes

    Error : Failed to init connection for drvr [SQLServer], connectionString [jdbc:jtds:sqlserver://10.200.21.32;databaseName=Quality;trusted_connection=yes]

    Any more ideas

    Please help !!

    Thanks,
    Phani
  • I have a Groovy script step that registers the JAR files at the beginning of all tests that require JDBC connections.

    I run the step before I have to make any connections. If I don't run it, I get a "failed to init connection" error every time.

    The following script registers the jTDS driver.


    import groovy.sql.Sql
    com.eviware.soapui.support.GroovyUtils.registerJdbcDriver( "net.sourceforge.jtds.jdbc.Driver" )


    I also use the SQL server name, NOT the IP address, in my connection string. Your DBA should be able to give you the name of the SQL server and its connection port.

    My connection string looks like this:

    jdbc:jtds:sqlserver://nameofSQLserver:portNumber;domain=nameofDomain;trusted_connection=yes
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    The connection string in the error does not look right, I think it should be:

    jdbc:jtds:sqlserver://10.200.21.32:1433/Quality;domain=yourdomain;trusted_connection=yes


    replacing '1433' with your DB port and 'yourdomain' with your domain.
  • Hi,

    I tried the same way. let me give you all the details which I'm trying it on my PC having both soap ui and sql on the same machine

    SOAPUI 4.0.0
    SQL Server 2008

    Copied the below files in the respective location

    ntlmauth.dll in C:\Program Files\eviware\soapUI-Pro-3.5.1\bin
    jtds-1.2.5.jar in C:\Program Files\eviware\soapUI-Pro-3.5.1\bin\ext

    and restarted the soapui

    Registered the driver properties in soapUI preferences.

    jdbc:jtds:sqlserver://<HOST:127.0.0.1>:<PORT:1433>/BFQuality;trusted_connection=yes

    but still im getting the same error

    "Failed to init connection for drvr [SQL Server], connectionString [jdbc:jtds:sqlserver://127.0.0.1:1433/BFQuality;trusted_connection=yes"

    Is there anything else.. I have removed the "domain" as it a PC.


    Thanks,
    Phani
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    You are using soapUI 4 - did you install this in the same directory as 3.5.1? I see that you have put the jar and the dll under 3.5.1 not 4.0.0.
  • Nullius's avatar
    Nullius
    Occasional Contributor
    Just for future references (been looking online for a few hours!):
    The MS driver DOES support integrated security (windows authentication).
    Download the latest driver from http://www.microsoft.com/download/en/de ... n&id=21599
    Unpack, copy 'sqljdbc.jar' or 'sqljdbc4.jar' (copying both resulted in a could not connect exception) to <soapui_dir>/bin/ext
    Then, copy 'sqljdbc_auth.dll' to <soapui_dir>/bin

    Use following connection string if using named instances:
    jdbc:sqlserver://<SERVER>;instanceName=<INSTANCE>;databaseName=<DATABASE>;integratedSecurity=true;

    Use following connection string if using server port:
    jdbc:sqlserver://<SERVER>:<PORT>;databaseName=<DATABASE>;integratedSecurity=true;
  • tona3743's avatar
    tona3743
    New Contributor
    Nullius, great post! Works like a charm even with newer Microsoft JDBC 4.0 driver.