When I use JDBC datasheet in Devetest and connect to SQL SERVER and execute a select query, getting an error as below Error: database query problem

Document ID : KB000008962
Last Modified Date : 14/02/2018
Show Technical Document Details
Issue:

I am trying to run a test in Dev test by taking data from SQL SERVER Database.

In the JDBC input step when I give the query for my database table, it everytime throws an error- database Query problem..

The data can be seen correctly in  SQL server studio but it does not run in Dev Test

I am able to test the connection from test step and also from datasheet

Environment:
Datasheet with SQL SERVER as a database.
Resolution:

This issue we notice if a connection string has not set in expected format

like:   connection string in test step or datasheet has given as below

jdbc:sqlserver://[SERVER_NAME]:{PORT}

   where as the SQL SERVER has multiple databases and the given query table exists on a database say DB1. Since the Devtest can not find on which database, this table exists. Due to that, we get an error.

To fix this error, please add databaseName parameter to connection string like below

jdbc:sqlserver://[SERVER_NAME]:{PORT};databaseName=DB1

and execute the query.