0

In my project we are using Microsoft SQL Server Management Studio for database testing and now we need to automate some flows that involves database testing. Below is the pre-login screenshot where we used to enter the servername as required, authentication as "Windows authentication". Then the username will automatically populate and there is no need to enter the password.

enter image description here

So to connect to the database I am using the below code but while executing I am getting error as "Login failed for user PILOTCORP\chatterp".

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con=DriverManager.getConnection("jdbc:sqlserver://ipaddress:portnumber;Databases=knxfpdbscrum\\FuelPact","username","password");
Statement st= con.createStatement();

In the code I have entered the database name as "knxfpdbscrum\FuelPact" since we need to select Database name as FuelPact.

enter image description here

Please help me.

Dmitrij Kultasev
  • 5,447
  • 5
  • 44
  • 88
Arijit Biswas
  • 81
  • 1
  • 3
  • 16
  • See if this helps https://thusithamabotuwana.wordpress.com/2012/07/19/connecting-to-sql-server-from-java/, https://community.oracle.com/thread/2419468 and https://stackoverflow.com/questions/16497998/jdbc-connection-to-mssql-server-in-windows-authentication-mode – Tarun Lalwani Sep 25 '17 at 08:46
  • take a look how to prepare connection strings https://www.connectionstrings.com/sql-server/ – Dmitrij Kultasev Sep 25 '17 at 09:09
  • @TarunLalwani can you please elaborate more on this issue. I went through all the URL's and they are confusing. – Arijit Biswas Sep 25 '17 at 12:50
  • Leave those look at https://stackoverflow.com/questions/37835929/connect-to-sql-server-with-windows-authentication-from-a-linux-machine-through-j – Tarun Lalwani Sep 25 '17 at 13:38

0 Answers0