Setting the Database Connect String - Synergex/SqlReplication GitHub Wiki

The Synergy SQL Connection API used by the replicator to connect to and interact with the database uses a connection string to identify the database server, database name and the database username and password. This connection string is stored in the environment variable REPLICATOR_DATABASE, or can be specified via the database command line option. The default connection that is configured in the development environment is:

VTX12_SQLNATIVE://SqlReplication/.///Trusted_connection=yes

This specifies a "DSN-less" connection to a local default instance of SQL Server, connecting to a database named SqlReplication, and authenticating via Windows authentication.

If you are using a local default instance of SQL server then this connect string will work for you out of the box, as long as you create a database named SqlReplication.

If the default connect string does not work for you then you will need to alter it:

  • If you are running replicator from the supplied Visual Studio project you will find that the REPLICATOR_DATABASE environment variable is set via the "common properties" tab in the Visual Studio project properties; change the value and then restart Visual Studio.

  • If you are running replicator from the supplied Workbench projects you will find that REPLICATOR_DATABASE environment variable is set in the project properties of the replicator project.

  • If you are running replicator as a Windows Service using the supplied batch file RegisterReplicatorService.bat you will find that the database command option is used.

Here are a few examples of common SQL Connection connect strings for use with SQL Server databases:

Database Instance Connect via Authentication Connect string
Local Either DSN SQL Server VTX12_SQLNATIVE:uid/pwd/dsn
Local Default DB name SQL Server VTX12_SQLNATIVE:uid/pwd/dbname/.///
Local Default DB name Windows VTX12_SQLNATIVE://dbname/.///Trusted_connection=yes
Local Named DB name SQL Server VTX12_SQLNATIVE:uid/pwd/dbname/.\\\instance///
Local Named DB name Windows VTX12_SQLNATIVE://dbname/.\\\instance///Trusted_connection=yes
Remote Either DSN SQL Server net:uid/pwd/dsn@port:server_ip!VTX12_SQLNATIVE
Remote Default DB name SQL Server net:uid/pwd/dbname/server_name///@port:server_ip!VTX12_SQLNATIVE
Remote Named DB name SQL Server net:uid/pwd/dbname/server_name\\\instance///@port:server_ip!VTX12_SQLNATIVE
Remote Named DB name Windows net://dbname/server_name\\\instance///Trusted_connection=yes@port:server_ip!VTX12_SQLNATIVE

A local connection should be used when the SQL Server database is hosted on the same system that the replicator is running on. A remote connection should be used when the SQL Server database is located on a different system, and requires that the Synergy OpenNET server is running on the database server system.

The various parts of the connect string are replaced as follows:

Value Replaced with
uid Username of the SQL Server login to use.
pwd Password of the SQL Server login to use.
dsn Name of an ODBC datasource to use.
dbname Name of the SQL Server database to connect to.
port TCP/IP port number that the Synergy OpenNet server is listening on (usually 1958) on the remote database server.
server_name Name of the remote SQL Server (Window server name).
server_ip The DNS name or TCP/IP address of the remote database server.
instance Name of the SQL Server named instance.

If you are using an ODBC DSN to connect to the database then you should:

  • Create the DSN wherever the database is located. For local databases the DSN should be defined on the local system. For remote databases the DSN should be created on the remote server system.
  • For local databases, create the DSN to match the bit-size that you are building the replicator application with. If you are building replicator for x86 then create a 32-bit System DSN. If you are building replicator for x64 then create a 64-bit System DSN.
  • For remote databases, create a DSN to match the bit size of the server that is hosting the database, and running the Synergy SQL OpenNet server. For 32-bit servers (rare), create a 32-bit System DSN on the server. For 64-bit servers (usual), create a 64-bit System DSN on the server.

You can find additional information about building connect strings in the SQL Connection Reference Manual.

For more information about configuring and running the SQL OpenNet Server refer to Configuring Connectivity Series in the Synergy/DE Installation Configuration Guide.