Top | Previous | Next |
Connecting to Microsoft SQL Server |
Microsoft SQL Server is a popular robust relational database produced by Microsoft. Ignition can connect to Microsoft SQL Server, however many users find difficulty in getting all of the settings and parameters correct. There are several different ways you can connect to Microsoft SQL Server (all using TCP/IP communication):
The most common method, the one out of the box, is to connect using an Instance Name and Windows Authentication.
SQL Server Instances Microsoft SQL Server supports multiple instances of the database running concurrently on the same computer. Each instance has its own name and set of system and user databases that are not shared between instances. Applications, such as Ignition, can connect to each instance on a computer in much the same way they connect to databases running on different computers. Each instance gets assigned a dynamic TCP/IP port on startup that it will listen on for any incoming requests. Since the port is dynamic and the application will not know what the new port is, it must connect using the instance name.
If the communication is over TCP/IP and the application knows the instance name, how will the application find which port to communicate over?
The answer is the Microsoft SQL Server Browser Service. The Microsoft SQL Server Browser program runs as a Windows service and listens for all incoming requests for resources and provides information, such as the TCP/IP port, about each instance installed on the computer. Microsoft SQL Server Browser also contributes to the following actions:
If the Microsoft SQL Server Browser service is not running, you are still able to connect to SQL Server if you provide the correct port number. For instance, you can connect to the default instance of SQL Server with TCP/IP if it is running on port 1433.
Check 1: Make Sure the Database has TCP/IP Enabled Ignition connects using TCP/IP, so the first step is to make sure your database has TCP/IP enabled. To check:
Check 2: Make Sure Microsoft SQL Server Browser is Running If you ARE connecting to your database using a NAMED INSTANCE you must make sure that the Microsoft SQL Server Browser is running. As mentioned earlier, the Microsoft SQL Server Browser translates the instance name to a TCP/IP port in order for your application (Ignition) to connect to it. To check:
Note: The service could be disabled so you may have to double click on it to enable the service before starting it up.
Scenario 1: Connecting Using Instance Name and SQL Authentication Since we are using SQL authentication, Microsoft SQL Server must allow this type of authentication. By default, Microsoft SQL Server only allows Windows authentication since it is more secure. To enable:
Now that Microsoft SQL Server accepts SQL authentication we can move to configuring Ignition. Follow these steps:
jdbc:sqlserver://Hostname\InstanceName Replace the "Hostname" with your databases IP address or hostname and replace the "InstanceName" with your databases instance name. Here are a couple of examples: jdbc:sqlserver://localhost\SQLEXPRESS jdbc:sqlserver://10.10.1.5\MSSQLSERVER
databaseName=test Replace "test" with your database name.
If the connection is "Faulted" click on the "Database Connection Status" link to find out why. Typically the username/password is incorrect or the user doesn't have the right permissions.
Scenario 2: Connecting Using Instance Name and Windows Authentication In Windows authentication mode, the username and password used to connect comes from the Ignition Windows Service logon. By default, the Ignition Windows Service is set to local system account which usually doesn't have privileges to connect. To connect using Windows authentication:
http://files.inductiveautomation.com/sqlserver_winauth_dlls/auth.zip
C:\Program Files\Inductive Automation\Ignition\lib\
Now we can move to configuring the database connection in Ignition. Follow these steps:
jdbc:sqlserver://Hostname\InstanceName Replace the "Hostname" with your databases IP address or hostname and replace the "InstanceName" with your databases instance name. Here are a couple of examples: jdbc:sqlserver://localhost\SQLEXPRESS jdbc:sqlserver://10.10.1.5\MSSQLSERVER
databaseName=test; integratedSecurity=true; Replace "test" with your database name.
Again, if the connection is "Faulted" click on the "Database Connection Status" link to find out why.
Scenario 3: Connecting Using Port and SQL Authentication Connecting using a port and SQL authentication is just like scenario 1 above except we specify a port instead of the instance name. Set the "Connect URL" in step 6 to: jdbc:sqlserver://Hostname:Port Replace the "Hostname" with your databases IP address or hostname and replace the "Port" with your databases TCP/IP port. Here are a couple of examples: jdbc:sqlserver://localhost:1433 jdbc:sqlserver://10.10.1.5:1433
Scenario 4: Connecting Using Port and Windows Authentication Connecting using a port and Windows authentication is just like scenario 2 above except we specify a port instead of the instance name. Set the "Connect URL" in step 6 to: jdbc:sqlserver://Hostname:Port Replace the "Hostname" with your databases IP address or hostname and replace the "Port" with your databases TCP/IP port. Here are a couple of examples: jdbc:sqlserver://localhost:1433 jdbc:sqlserver://10.10.1.5:1433
Common Problems TCP/IP Communication Not Enabled SQL Server requires that you explicitly turn on TCP connectivity. To do this, use the SQL Server Configuration Manager, located in the Start menu under "Microsoft SQL Server>Configuration Tools". Under "SQL Server Network Configuration", select your instance, and then enable TCP/IP in the panel to the right. You will need to restart the server for the change to take affect. Window Firewall When connecting remotely, make sure that Windows Firewall is disabled, or set up to allow the necessary ports. Normally ports 1434 and 1433 must be open for TCP traffic, but other ports may be required based on configuration. SQL Server Browser Process Not Running To connect to a named instance, the "SQL Server Browser" service must be running. It is occasionally disabled by default, so you should verify that the service is not only running, but set to start automatically on bootup. The service can be found in the Windows Service Manager (Control Panel>Administrative Tools>Services). Mixed Mode Authentication Not Enabled Unless selected during setup, "mixed mode" or "SQL authentication" is not enabled by default. This mode of authentication is the "username/password" scheme that most users are used to. When not enabled, SQL Server only allows connections using Windows Authentication. Due to the ease of using SQL Authentication over Windows Authentication, we recommend enabling this option and defining a user account for Ignition. To enable this, open the SQL Server Management Studio and connect to the server. Right click on the instance and select "Properties". Under "Security", select "SQL Sever and Windows Authentication mode". |