Forum Discussion

TSGARDN's avatar
TSGARDN
New Contributor
8 years ago

JDBC Step - Problem Connecting

Good Afternoon,

 

I'm attempting to connect to Microsoft SQL Server. I've downloaded the correct sqljdbc4.jar library and have tried doing this with both Groovy and the JDBC Request with no success so far. For reference, I'll include both the Groovy script and credentials for the JDBC Request below.

 

 

Groovy Script syntax:

 

import groovy.sql.Sql

class GroovySQLTest{
 static void main(String[] args) {
  def db_url   = "jdbc:sqlserver://SERVERNAME:1433;DatabaseName=DATABASENAME"
  def db_username = "USERNAME"
  def db_password = "PASSWORD"
  def db_driver   = "com.microsoft.jdbc.sqlserver.SQLServerDriver"
  def sql = Sql.newInstance(db_url,db_username,db_password,db_driver)
  sql.execute "Select Top 1 * From TABLE"
 }
}

 

 

JDBC Request syntax:

 

Driver: MSSQL(MicrosoftDriver)/com.Microsoft.sqlserver.jdbc.SQLServerDriver

Host: SERVERNAME

Port: 1433

User: USERNAME

Password: PASSWORD

Database: DATABASENAME

 

 

 

For the Groovy script, does anything stand out as incorrect for the syntax? I've tried fully qualifying the table name (server.database.table) in the script's sql.execute command, but this hasn't worked. 

 

For the JDBC Request, everything looks to be fairly simple as far as what credentials I should supply. Again, does the database name have to be fully qualified?

 

At a loss here as to what I'm doing wrong. Any help would be greatly appreciated.

 

 

 

Thanks,

 

Tyler

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3
    Not sure what is the error you are getting.

    1. check if you have copied jar file under READYAPI_HOME/bin/ext directory.
    2. restart ready api
    3. Register the driver using below statement before sql instance
    com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("com.Microsoft.sqlserver.jdbc.SQLServerDriver")

    4. change to (note only 3 arguments instead of 4) Sql.newInstance(db_url,db_username,db_password)
    • TSGARDN's avatar
      TSGARDN
      New Contributor

      Here's the error message I'm getting:

       

      org.codehaus.groovy.runtime.InvokerInvocationException: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host VMBKSA69901M4Y, port 1433 has failed. Error: "connect timed out. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

      • nmrao's avatar
        nmrao
        Champion Level 3
        You can follow the instructions of error message.
    • testhrishi's avatar
      testhrishi
      Frequent Contributor

      hi nmrao - Can you please elaborate on this step? -

      Register drivers using command below

      "com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("com.Microsoft.sqlserver.jdbc.SQLServerDriver")"

      I had JDBC configured with soapUI , with ReadyAPI it does not work

       I have all proper drivers in ext directory

       

      How can make sure the test connection to database works again?