Forum Discussion

ilovechiku's avatar
ilovechiku
Contributor
9 years ago

SOAP UI 5.2.1 and database validations failing

 

 I have soap ui free version 5.2.1 

iam using windows 10. Have the latest JRE 8.0

What am confused is what .jar file should i be using. It is giving me a error on connecting to the database at the line 

 

testRunner.testCase.setPropertyValue("EmployeeID", getEmployeeIdFromDB(db))

 

below is my code:

 

/*import groovy.sql.Sql
com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver")
def db = connectDataBase()
testRunner.testCase.setPropertyValue("EmployeeID", getEmployeeIdFromDB(db))
log.info testRunner.testCase.getPropertyValue("EmployeeID")
closeDatabase(db)

*/

 

 

Error am seeing is 

2016:INFO:com.microsoft.sqlserver.jdbc.SQLServerDriver

 

under soapUI log i see

 

ERROR:An error occurred [Cannot invoke method firstRow() on null object], see error log for details

 

Could this be because of the out dated .jar file. Iam currently having sqljdbc4.jar  under the location

 

C:\Program Files\SmartBear\SoapUI-5.2.1\bin

 

Please let me know what is going on ?. Is the jar file too old?. is the location wrong?

5 Replies

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi,

     

    I can't coment on the the driver file suitability, as I dont have MS SQLServer to test with, but the location of where you have copied the driver jar sounds like it could be wrong - normally it should be copied to:

     

    bin/ext

     

    This should be the location for all external libraries (jar files) that you want to be added to the SoapUI class path.

     

    As for the code, I can't see the contents of that connectDataBase() method, but here is an example of a working Groovy SQL script for the H2 DB, should be very similar, just a different driver string:

     

    import groovy.sql.Sql
    import org.h2.Driver
    
    com.eviware.soapui.support.GroovyUtils.registerJdbcDriver("org.h2.Driver")
    
    def db = Sql.newInstance("jdbc:h2:mem:test", "org.h2.Driver")
    
    db.eachRow("select * from quotes"){invoice->
             log.info invoice.toString()
    }

    Hope this helps,

    Cheers,

    Rupert

     

    • ilovechiku's avatar
      ilovechiku
      Contributor

      no that didnt help much :smileysad:

      def dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver ,org.h2.Driver"
      def db = Sql.newInstance(dburl, dbUserName, dbPassword, dbDriver)

       

      could this syntax be wrong ?

       

  • kondasamy's avatar
    kondasamy
    Regular Contributor

    I could able to connect to MS SQL server using the below connection string,

     

    GroovyUtils.registerJdbcDriver( "com.microsoft.sqlserver.jdbc.SQLServerDriver" )
    sql = Sql.newInstance("jdbc:sqlserver://$DB_URL;databaseName=$DB_NAME;user=$DB_LOGIN;password=$DB_PWD","com.microsoft.sqlserver.jdbc.SQLServerDriver")

    Also the DB_URL should be in the format - 192.17.193.21:1433.

     

    Thanks,

    Kondasamy