How to connect Mule application to SQL Server with Windows Authentication - sql-server

I have SQL Server installed on my PS. I can connect to it using Windows Authentication and SQL Authentication using SQL Server Management Studio. But, when I try to connect it from Mule it's always a connection error.
Things I've tried so far:
Used default option provided by MuleSoft for SQL Server.
Tried turning my firewall off.
Tried integretaedSecurity=true.
Tried Generic connection and provide my own JDBC URL
No luck so far. Any help please?

It will be good if you can provide the exact error.
But mean while,
Try enabling TCP port in the system.
Below are the steps to enable TCP (in local machine).
Open the 'Sql Server Configuration Manager' application.
In the left pane, go to 'SQL Server Network Configuration' -> 'Protocols for [instance-name]'
Right-click on 'TCP/IP' and select 'enable'.
Restart the 'SQL Server ([instance-name])' windows service or restart your machine.

You need to ensure that the DLL sqljdbc_auth.dll is in the path of execution for Mule. Note that integrated authentications will work only when Mule is executing in a Windows OS. It will not work if deployed to Linux, CloudHub or Runtime Fabric.
Full instructions: https://help.mulesoft.com/s/article/How-to-use-Windows-Authentication-in-Database-Connector-with-Microsoft-SQL-Server-in-Mule4

Related

Not Connecting to the SQL Server

I installed SQL Server Management Studio on my machine and once it was succesfully installed, I tried to connect to the local Database Engine but I was not succesful connecting to it it showing up an error showing as Cannot connect to the Local or having Network Related problems in the connection. I got a question here once I download the SQL Server management studio Do I need to do something else to get connected to the Local SQL Server.
Thanks,
Pranay.
No you don't need by default you can connect to local machine. You might have a problem connecting from other machine in the network if TCP is not enabled, but local should work.
Make sure you typed your 'sa' password correctly or use Windows Authentication.
Did you check in Windows Services? There is the service SQL Server (SQLEXPRESS) and SQL Server Browser which must be running.
Go to your Sql Server Configuration Manager and make sure that SQL Server is running. Otherwise right click and click Start.
And sometimes you need to Enable TCP/IP in your Protocols again in your Sql Server Configuration Manager

SQL server cannot be connected

I am developing an Asp.net MVC4 application wherein i am using SimpleMemberShip provider for authorization and i am using database MSSQL Server 2012 on the same machine.
When i openup the SQL server management studio and connect to the database by using windows authentication and sql server authentication, in both ways it is getting connected.
But when i am specifying the connection string in the application with correct credentials,
Still the application is unable to connect to the database.
I have restarted the system but it did not resolve the issue.
I have opened the configuration tool of SQl server and enabled TCP\IP and namepipe client protocols for sql client as well as for the server and restarted all the sql server related services.
But still issue is remaining, i am sure about connection string it is 100% correct.
I am scratching my head from past 5 hrs but could not track down the issue.
Please tell me the possible solutions.
I would check firewall. If you have firewall (either default windows or using some AV) then temporarily disable it and see if it works.

ASP/SQL Server Express: Could not open a connection to SQL Server [53]

Windows 7, IIS 7.5, SQL Server 2008 R2, ASP classic (website I want to upgrade, but need to make it works).
connection string:
Provider=SQLNCLI10; Data Source=.\SQLExpress; Initial Catalog=shoshvi_sql-db;Integrated Security=SSPI;Connect Timeout =1
I am getting this annoying error:
Microsoft SQL Server Native Client 10.0 '80004005'
Named Pipes Provider: Could not open a connection to SQL Server [53].
filename.asp, line 15
What I tried, as I remember:
Test connection using SSMS (works, to localhost and to other server in LAN)
Test connection using SQLCMD (works, to localhost and to other server in LAN)
Tried many datasources/servers ( name\SQLExpress, .\SQLExpress, .\SQLEXPRESS)
Tried to change settings in Start Menu\Programs\Microsoft SQL Server 2008\Configuration Tools, enable TCP/IP, Named Pipes, look all sub items and find wrong configuration.
after any change, I was restarted service.
Tried to enable SQL Server Browser.
Tried to connect to other SQL Server in the same network, using SA and SA password (in the other "server" I could use IIS/ASP/MSSQL and works fine).
Tried to disable Windows Firewall
Tried to enable remote connections to SQL Server Express
Tried Integrated Security=SSPI
Tried Windows Administrator password
Tried change to TCP/IP (and get other error, same reason)
Tried to search google, and stackOverflow and other for an idea.
Tried similar questions here.
What more?
Thanks !
Try this. And make sure you have TCP/IP enabled under 'SQL Native Client Configuration' on SQL Configuration Manager.
PROVIDER=SQLNCLI;DRIVER={SQL server};SERVER=127.0.0.1;DATABASE=shoshvi_sql-db;UID=username;PWD=password;
Double-check that any ALIAS you're using is created properly.
I was encountering exactly the same error and it turned out to be that I hadn't created the alias used in a script when trying to run it on a new machine.

Unable to connect to SQL Server instance remotely

I’m trying to access the SQL Server instance on my VPS from SQL Server Management Studio on my local machine. It’s not working (the error I’m getting is:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections.
I think this is because I need to configure the database engine to allow remote connections (correct me if I’m wrong!). So I’ve found this step-by-step guide to help me do that: http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/ I’ve got to point 10 in the guide and I am now stuck! I don’t have SQL Server Management Studio installed on my VPS. Anyway, this has left me with two options:
Install SSMS
Find another way to do point 10 onwards in the guide without having SSMS installed
I tried installing SSMS on my VPS using the Web Platform Installer but it keeps failing. I don’t know why it’s failing because it doesn’t seem to give a reason why. Does anyone know how I could allow remote connections a different way?
The version of SQL Server installed on my VPS is SQL Server 2008 R2 Express.
Update:
I have tried to disable the firewall on both my laptop and VPS to see if it is a firewall issue. This made no difference to the error message.
Another Update:
Having now been able to install SSMS (I installed directly from the website rather than using the WPI), I have been able to check that the server is configured to allow remote connections (I went to SSMS, connected to the SQL Server instance, right-clicked on the connection, clicked Properties, went to the Connections tab. "Allow remote connections to this server" is already ticked).
SOLUTION
Thanks to everyone for helping me get to this solution! I've finally managed to get it to work! I followed Filip De Vos's advice and opened the ports in the Firewall on my VPS and then I received a different error message. This led me to investigate further and I found that I was using the wrong credentials to login! So I've set a password for the sa user and I've managed to login using that! Thanks again!
To enable mixed authentication you can change the following registry key:
HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\LoginMode
Update the value to 2 and restart the Sql Server service to allow mixed authentication. Note that MSSQL.1 might need to be updated to reflect the number of the SQL Server Instance you are attempting to change.
A reason for connection errors can be a virus scanner installed on the server which blocks sqlserver.exe.
Another reason can be that the SQL Server Browser service is not running. When this service is not running you cannot connect on named instances (when they are using dynamic ports).
It is also possible that Sql Server is not setup to listen to TCP connections and only allows named pipes.
In the Start Menu, open Programs > Microsoft SQL Server 2008 >
Configuration Tools > SQL Server Surface Area Configuration
In the Surface Area Configuration utility, click the link "SQL Server
Configuration Manager"
Expand "SQL Server Network Configuration" and
select Protocols.
Enable TCP/IP. If you need Named Pipes, then you can
enable them here as well.
Last but not least, the Windows firewall needs to allow connections to SQL Server
Add an exception for sqlserver.exe when you use the "Dynamic Port" system.
Otherwise you can put exceptions for the SQL Server ports (default port 1433)
Also add an exception for the SQL Server Browser. (udp port 1434)
More information:
How to: Configure a Windows Firewall for Database Engine Access
Server Connectivity How-to Topics (Database Engine)
As a last note, SqlLocalDB only supports named pipes, so you can not connect to it over the network.
In addition to configuring the SQL Server Browser service in Services.msc to Automatic, and starting the service, I had to enable TCP/IP in: SQL Server Configuration Manager | SQL Server Network Configuration | Protocols for [INSTANCE NAME] | TCP/IP
Launch SQL Server Configuration Manager on your VPS.
Take a look at the SQL Server Network Configuration. Make sure that TCP/IP is enabled.
Next look at SQL Server Services. Make sure that SQL Server Browser is running.
Restart the service for your instance of SQL Server.
Open the SQL Server Configuration Manager....
2.Check wheather TCP and UDP are running or not....
3.If not running , Please enable them and also check the SQL Server Browser is running or not.If not running turn it on.....
Next you have to check which ports TCP and UDP is using. You have to open those ports from your windows firewall.....
5.Click here to see the steps to open a specific port in windows firewall....
Now SQL Server is ready to access over LAN.......
If you wan to access it remotely (over internet) , you have to do another job that is 'Port Forwarding'. You have open the ports TCP and UDP is using in SQL Server on your router. Now the configuration of routers are different. If you give me the details of your router (i. e name of the company and version ) , I can show you the steps how to forward a specific port.
I had the same issue where my firewall was configured properly, TCP/IP was enabled in SQL Server Configuration Manager but I still could not access my SQL database from outside the computer hosting it. I found the solution was SQL Server Browser was disabled by default in Services (and no option was available to enable it in SQL Server Configuration Manager).
I enabled it by Control Panel > Administrative Tools > Services then double click on SQL Server Browser. In the General tab set the startup type to Automatic using the drop down list. Then go back into SQL Server Configuration Manager and check that the SQL Server Browser is enabled. Hope this helps.
Disable the firewall and try to connect.
If that works, then enable the firewall and
Windows Defender Firewall -> Advanced Settings -> Inbound Rules(Right Click) -> New Rules -> Port -> Allow Port 1433 (Public and Private) -> Add
Do the same for Outbound Rules.
Then Try again.
I recently upgraded from SQL 2008 R2 to SQL 2012 and had a similar issue. The problem was the firewall, but more specifically the firewall rule for SQL SERVER. The custom rule was pointed to the prior version of SQL Server. Try this, open Windows Firewall>Advanced setting. Find the SQL Server Rule (it may have a custom name). Right-Click and go to properties, then Programs and Services Tab. If Programs-This program is selected, you should browse for the proper version of sqlserver.exe.
If you have more than one Instances... Then make sure the PORT Numbers of all Instances are Unique and no one's PORT Number is 1433 except Default One...
Open SQL Server Configuration Manager.
Click SQL Server Services, on the right side choose the server you've created during installation (by default its state is stopped), click once on it and a play button should appear on the toolbar. Click on this play button, wait til its state turns to "Running". Now you're good.
Open SQL Server Management Studio; switch the "Server Type" to "Database Engine" and "Authentication" to "SQL Server Authentication". The default login is "sa", and the password is the password that you chose on creating the server. Now you're good to work.
In my case the problem was caused by the inconsistency between computer names. In system settings my computer was named with some long name, but apparently the name used for some certain communications was trimmed.
I changed the name in the settings to a shorter one and it worked.
I had built both a console app and a UWP app and my console connected fine, but not my UWP. After hours of banging my head against the desk - if it's a intranet server hosting the SQL database you must enable "Private Networks (Client & Server)". It's under Package.appxmanifest and the Capabilities tab.Screenshot
Before download the last version and update your sql server to fix errors of TLS 1.2 on Sql Server 2012. For more information, check here.

Unable to connect to remote sql server

I have an SQL Server 2008 hosted on a different computer in a different domain. I am able to ping to this machine using the IP address, but not using the machine name. I have also checked the settings of the sql server instance and it is configured to provide access to remote connections.
(Allow remote connections, tcp/ip enabled)
When I try to find this server using Sql server management studio 2008 or VS 2008, I get the error saying that the server cannot be found.
what could be the reason for this?
Please check SQL Browser service is running.
Please make sure you are providing valid authentication details.
Also make sure that TCP/IP connections are allowed by the SQL Server instance by checking the SQL Server Configuration Manager. If you are using an express version of SQL Server then all remote connections are typically disabled by default.
You need to create a trust relationship between the domains I think, it's been a while since I've done things between domains.
Windows Firewall will block SQL Server connection requests from a client machine by default. These are the steps I normally do to allow SQL Server through Windows Firewall:
Windows Firewall-> Allow app or feature through Windows Firewall-> Change
Settings-> Allow another app-> Browse to SQL Server exe (eg: C:\Program
Files (x86)\Microsoft SQL
Server\MSSQL10.SQLEXPRESS\MSSQL\Binn\sqlservr.exe)-> Open-> Add.
Windows Firewall-> Allow app or feature through Windows Firewall-> Change
Settings-> Allow another app-> add SQL Brower service by going to
C:\Program Files (x86)\Microsoft SQL Server\90\Shared\sqlbrowser.exe.
SQL Server configuration Manager-> SQL Server Network Configuration->
Protocols for Your_SQL_Instance-> Right click TCP/IP on the right pane
and enable.
The SQL Server instance does not need to be configured to run on 1433 and therefore no need to open the 1433 port through the firewall. SQL Browser will find it for you whichever port it is running on.

Resources