0

I created a new database in SQL Server(first time using it) after choosing Windows Authentication as an Authentication type As you can see in the pic

Then I tried to add the SQL Server to netbeans pic2[![][2]3

But when I try connecting to the database I always get a connection error pic4

i'mgnome
  • 483
  • 1
  • 3
  • 17
  • Sorry but your first image (and images are discouraged for many reasons) does not indicate you "created a database". SSMS and the SQL Server database engine are different downloads. Did you install SQL Server or just SSMS? If the latter, then you need to do the former. – SMor Jan 14 '20 at 16:36
  • Actually I installed both(as far as i know, when i finished installing SQL Server it prompted that i might want to install SSMS so i did) – i'mgnome Jan 14 '20 at 16:40
  • I'm pretty sure that NetBeans won't grab your current user credentials because that isn't how Java powered applications typically work, esp. when it doesn't have an authentication type selector. Have you tried actually typing them in "User Name" and "Password"? – Álvaro González Jan 14 '20 at 17:42
  • If it can actually be done, you'll probably need to set details in the JDBC URL. Here's the first [Google hit](https://stackoverflow.com/questions/16497998/jdbc-connection-to-mssql-server-in-windows-authentication-mode) I found to give you an idea. – Álvaro González Jan 14 '20 at 17:43

1 Answers1

0

Check the MSSQL port

First, you need to check that MSSQL indeed listens on the default port 1433. To check it run the script or use other methods:

USE master
GO
xp_readerrorlog 0, 1, N'Server is listening on' 
GO

In my case, it listens on 1444, so you might need to change the port in JDBC connection string:

enter image description here

Choose version of sqljdbc_auth.dll

Second, to use integrated security you need to put sqljdbc_auth.dll in NetBeans bin path (in my case for 8.1 it's C:\Program Files (x86)\NetBeans 8.1\bin).

The sqljdbc_auth.dll ships with Microsoft JDBC and you can find it in sqljdbc_4.2\enu\auth\x64 (or x86) directory.

You need to choose the right version of sqljdbc_4.2. If NetBeans uses x86 version of java then choose x86 version of sqljdbc_auth.dll. You can check it with NetBeans in Help -> About. In my case it uses x86 version:

enter image description here

If you have x64 version then it would look something like this:

enter image description here

Change jdbc connection string

After that add integratedSecurity=true to the JDBC URL for example:

jdbc:sqlserver://SRV-01\SQL2008R2:1444;integratedSecurity=true

To check other JDBC related issues you can find log in View -> IDE Log menu. Hope this helps.

Dmitry.M
  • 2,833
  • 1
  • 17
  • 30