Database connection to SQl Server 2008 R2
Hi All,
I have imported sqljdbc4.2 jars in Soapui lib directory and using groovy want to connect to SQL Server 2008 R2 Edition with windows authentication.Please find the below code for and correct if I am wrong in my assumption.
import groovy.sql.Sql
try{
def dbURL = "jdbc:sqlserver:/servername:1433/databasename"
def dbUsername = "username"
def dbPassword = "password"
def dbDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
def sql = Sql.newInstance(dbURL,dbUsername,dbPassword,dbDriver)
log.info "Connected to database successfully"
}catch(Exception e){
log.info "some db error"
log.info e.getMessage()
}
For the above code I am getting below error :
- Mon Aug 17 11:53:48 IST 2015:INFO:some db error
- Mon Aug 17 11:53:48 IST 2015:INFO:No suitable driver found for jdbc:microsoft:sqlserver:/server name:1433/database name
It is going to catch block and executing the statements.
Please help if missing any workaround for it.
Regards,
Niyaz