1

I use to use MYSQL for my database needs. I switched to MSSQL because somebody wanted me to develop an application on it. I used MS SQL Server 2008 earlier and then upgraded to MS SQL Server 2012. In JDBC, I used the following:

   String connectionUrl="jdbc:sqlserver://"+sname+";DatabaseName="+dbname;

where sname is my 'machinename/instancename' (which is correct) and dbname is self explanatory. I also tried various other strings with port numbers. Tried all of this:

1) Right clicked on Sql Server in Sql Management Studio (SMS) -> Connections -> Allow remote connections.

2) Right clicked on Sql Server in Sql Management Studio (SMS) -> Security -> Allow remote connections -> Set Auth mode to Win and Sql auth mode (i.e. mixed mode)

3) Even disabled firewall.

4) Sql Server Configuration Manager -> Network Configuration -> Protocols -> Enabled Shared memory, Named pipes, TCP/IP.

5) SQL Browser service is enabled.

6) Here it says 'Server is listening on [ 'any' 1433]' should be listed in my SQL Server log which ISN'T. Even after repetitive enabling of 1433 as in port.

7) I have also:

Seen a lot of links like these which didn't help. Tried all the answers in this . In the answer somebody mentioned the telnet command. Running the

  telnet 127.0.0.1 1433

I get 'Could not open connection to the host, on port 1433: Connection failed'. I've tried port opening through the firewalls advanced settings in Control panel. I have already tried 'advfirewall netsh' to enable ports.

I am using this to basically develop a web application on NetBeans. And a simple matter of database connectivity has taken all day. Its as if Microsoft is making it hard for us to use MS SQL Server.

The error I'm getting is:

   se:com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host [host name], port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall."

Can anybody help point out something I'm missing? Here is a view of my Configuration Manager window opened from the 2012 folder (I have both 2008, 2012 folders in my Programs, idk why because after updation shouldn't 2008 version have been removed?):

Community
  • 1
  • 1
user2816215
  • 399
  • 1
  • 4
  • 17

1 Answers1

0

What finally worked for me (after hours of searching on all kinds of blogs):

  1. Installed MS SQL 2012 with a default instance. This removed the 2008 version.
  2. Redid all of the above. Plus, added an outbound rule for port 1433. Found the part about outbound rule after much searching. Everybody says only about the inbound rule.
  3. Restarted the services (SQL Browser, SQL Server) in Configuration Manager. No changes take place until it starts.
  4. Used this connection string (with user="sa" and servername as the default instance name. Also used the password for sa) :

    url = "jdbc:sqlserver://" + servername + ":1433;user=" + user + ";password=" + dbPass + "; namedPipe=true;DatabaseName=" + dbName;
    

Note: I restart the server again every time I log into the computer from Start-> All Programs -> Microsoft SQL Server 2012 ->Configuration Tools-> SQL Server Configuration Manager->SQL Services-> Right click on SQL Server with my default instance name and start it. Then, running the telnet command:

telnet 127.0.0.1 1433

shows a blank screen. Which means port 1433 is working now.

user2816215
  • 399
  • 1
  • 4
  • 17