Java – unable to connect to SQL Server database using JDBC
I am trying to connect to an existing database in SQL Server 2012n using NetBeans 8
Using the connection wizard, I select SQL Server 2012 and enter credentials and fields
But I received a message that I couldn't establish a connection
You can see a screenshot of the input fields:
I also try to use "localhost" instead of "Stijn", which doesn't work I also try to use the default port "1433" It's no use, but what port should this be? Where can I see the port I'm using? Maybe the mistake is the port, otherwise I don't know where I made a mistake
Solution
Go to SQL Server Configuration Manager – > sql server network configuration – > protocol of sqlexpress – > TCP / IP (double-click properties)
Set enable to yes on the protocol page On the IP address page, scroll to the bottom TCP dynamic port: 54629 TCP port: 1433 apply and confirm
Establish connection: host: localhost port: 1433 your credential instance field = blank
This should work