SQL Connection and xfODBC on Windows

This topic explains how to configure SQL Connection and xfODBC for remote use with SQL OpenNet and for local (stand‑alone) use.

Understanding SQL OpenNet on Windows

On Windows, you can run SQL OpenNet with either the vtxnetd program (which is the default) or the vtxnet2 program. Both are started by the service program sqld. The one you should use depends on the data source you need to connect to. For program syntax, see vtxnetd and vtxnet2 programs.

The vtxnetd program

The vtxnetd program is a multi‑threaded server, which listens on the selected port and starts threads to service the connection requests and perform the requested work. The driver name (e.g., vtx12_SQLNATIVE) in the connect string determines the DLL that vtxnetd attaches to its worker thread to service the connection. You can use vtxnetd in the following circumstances:

Using the multi‑threaded vtxnetd reduces start‑up overhead on initial connections and has a small performance advantage over the multiple program approach of vtxnet2 (see below). If a connection request is made via vtxnetd to a driver that does not support multi‑threading, the connection is rejected.

The vtxnetd program offers the ability to specify how existing connections are handled when SQL OpenNet is shut down, which vtxnet2 does not support. See Stopping and removing SQL OpenNet.

The vtxnet2 program

The vtxnet2 program is a listener daemon, which listens on the requested port and creates child processes to service client requests. The driver name portion of the connect string (e.g., !vtx12_SQLNATIVE) determines the server executable and its associated DLL, which are used to create the process to service the connections. To use vtxnet2, you must edit the opennet.srv file; see Customizing the opennet.srv file.

The sqld program

The service program sqld starts either the vtxnetd or vtxnet2 program, and then polls the program periodically to verify that it is still running. The service name for sqld is SynSQL, and the display name is “Synergy/DE OpenNet Server”. Sqld reads the opennet.srv file, which contains the daemon start‑up commands and parameters as well as needed environment variable settings. See sqld program and Customizing the opennet.srv file for more information.

SQL Connection and xfODBC: using SQL OpenNet

To use SQL OpenNet with SQL Connection or xfODBC, you need to do the following on your SQL OpenNet server machine:

Specifying the port number

You must specify the port number used by SQL OpenNet in the TCP/IP services file. Open the services file in %windir%\system32\drivers\etc and add this line:

vtxnet nnnn/tcp #Synergy/DE SQL OpenNet server

where nnnn is the port number. The default port number is 1958, but you can specify any unused port.

Important

If you use a non‑default port, you must also do the following:

Registering, starting, and testing SQL OpenNet

SynSQL must be started by a user with administrator privileges.

1. Before starting SQL OpenNet, you must first register the SynSQL service. Do one of the following:
sqld -r 
Note

You can register and start the SynSQL service in one step with the sqld ‑rs option.

2. There are several ways to start SynSQL. Do one of the following:
net start synsql
3. To verify that the server is running, at a command prompt run vtxping:
vtxping [-pport] server_name

where port is the port number that the server is running on, and server_name is the host name of the SQL OpenNet machine. If no port is specified, the default port specified in the services file is used.

If the server starts successfully, you’ll receive a “vtxnetd is alive and kicking” message. If there’s a problem, you’ll see an error message. See vtxping utility for more information. You can check the Windows event log for additional information. You may want to start sqld with the ‑l option for more detailed logging; see sqld program.

SQL OpenNet is now configured. For SQL Connection, you must license your database drivers before you can run the example programs. See Testing SQL Connection (client or stand‑alone) for information on the example programs. See Configuring License Manager for licensing information.

Stopping and removing SQL OpenNet

You must stop the service before you can remove (unregister) it. When you stop SQL OpenNet, no new connections can be made. The behavior of existing connections depends on whether you are using vtxnetd or vtxnet2:

To change this behavior such that existing connections are not terminated, remove the ‑w option from the command line in opennet.srv. This is not recommended, as the vtxnetd program will not completely shut down until all child processes are terminated. See Shutting down vtxnetd on Windows (‑w) for details.

To stop and remove SQL OpenNet,

sqld -x

To stop SQL OpenNet, do one of the following:

sqld -q
net stop synsql

To remove SQL OpenNet, do one of the following:

sqld -x

Customizing the opennet.srv file

Editing the opennet.srv file is optional. The opennet.srv file, located in synergyde\connect, is read by sqld. It contains the command line that is used to start vtxnetd or vtxnet2. By editing that command line, you can use a port other than the default, run multiple servers, and so on. You can also define environment variables in the opennet.srv file.

Note

The opennet.srv file is not overwritten when you upgrade Connectivity Series, nor is it removed when you uninstall. We distribute a file named opennet_base.srv (also located in synergede\connect), which contains default settings and can be used as a reference.

See below for information on using vtxnet2 instead of the default vtxnetd, defining environment variables, caching, and changing the polling interval. For information on the following, see the vtxnetd and vtxnet2 program syntax in vtxnetd and vtxnet2 programs:

Using vtxnet2

The default program, vtxnetd, is a multi‑threaded server that generally performs better than vtxnet2. However, you can use vtxnet2 when you want SQL OpenNet to be a listener daemon that creates child processes rather than a multi‑threaded server. The start‑up lines for both vtxnetd and vtxnet2 are included in the opennet.srv file. To use vtxnet2, just comment out the vtxnetd line and enable the vtxnet2 line. See Understanding SQL OpenNet on Windows for additional information about vtxnetd and vtxnet2.

Defining environment variables

Any environment variables used by SQL OpenNet, such as those that specify the location of your data files, can be defined in the opennet.srv file. Define environment variables towards the beginning of the file, before the vtxnetd or vtxnet2 start‑up line.

Caching

You can enable system catalog caching for xfODBC by editing the “syngenload” line in the opennet.srv file. For more information, see Improving performance with system catalog caching.

Changing the polling interval

By default, the sqld program polls (checks) vtxnetd/vtxnet2 every 10 minutes to verify that it is still running. If vtxnetd/vtxnet2 stops unexpectedly, users will be unable to connect, and yet no error will be recorded in the Windows event log (nor will the status of the SynSQL service change in the Component Services dialog box) until the next poll takes place. Consequently, you may want a shorter polling interval, so that should vtxnetd/vtxnet2 stop unexpectedly, sqld will report the event promptly in the Windows event log.

To change the polling interval, in the opennet.srv file, remove the comment (#) at the beginning of the OPENNET_POLL_TIME line and specify the desired polling interval in milliseconds. For example, to set the polling interval to one minute, you’d enter

OPENNET_POLL_TIME=60000   

SQL Connection: configuring client or stand‑alone access

This section describes how to configure SQL Connection as a client and how to test your client/server or stand‑alone configuration.

Configuring SQL Connection (client)

1. Add the following line to your TCP/IP services file in %windir%\system32\drivers\etc:
vtxnet nnnn/tcp #Synergy/DE SQL Connection

where nnnn is the port number. The default port number is 1958, but if you configured SQL OpenNet to run on a different port, specify that port number here.

2. Run vtxping to test your connection to the server:
vtxping [-pport] server_name

where port is the port number on which the client will connect to SQL OpenNet, and server_name is the host name of the SQL OpenNet machine. If no port is specified, the default port specified in the services file is used.

If the network connection is working properly, you’ll receive a “vtxnetd is alive and kicking” message. If there’s a problem, you’ll see an error message. See vtxping utility for more information.

Testing SQL Connection (client or stand‑alone)

1. Set the SQL_CONNECT environment variable to specify a connect string.
net:connect_string@[port:]host!driver_name

where connect_string contains the driver‑specific information to be passed to the database driver, port is the port number on which SQL OpenNet is running (required for non‑default port), host is the server system’s unique name, and driver_name is the driver name (e.g., vtx12_SQLNATIVE).

The syntax for connect_string depends on the driver. For a list of driver names and the connect syntax to use with them, see Building connect strings.

For example, to connect to an SQL Server database on a remote Windows machine, you might enter

set SQL_CONNECT = net:user_name/manager/mydsn@win_serv!vtx12_SQLNATIVE

driver:connect_string

where driver is the name (e.g., vtx12_SQLNATIVE) of the database driver, and connect_string contains the required information to be passed to the database driver. The syntax for connect_string depends on the driver. See Building connect strings for complete information.

For example, to connect to an Oracle 11 database, the connect string consists of the user ID and password. So, you might enter

set SQL_CONNECT = vtx0_11:scott/tiger
2. Go to the synergyde\connect\synsqlx directory to compile, link, and run the example programs. There are several example programs (exam_create_table, exam_fetch, etc.), which are used to test your connection and set‑up. Run exam_create_table first: it creates a table, which is then used by the other example programs.

For example:

dbl exam_create_table
dblink exam_create_table
dbr exam_create_table

If this test is unsuccessful, note the error(s) and refer to Error Logging and Messages. For more information about the example programs, see Writing an SQL Connection program.

Your SQL Connection configuration is now complete. See the SQL Connection Reference and the release notes, REL_CONN.TXT, for more information about using SQL Connection.

xfODBC: testing the network connection for client access

After configuring SQL OpenNet on the server and installing Connectivity Series or xfODBC Client on the client, you should test the network connection before attempting to access data using xfODBC. To do this, run vtxping on the client machine:

vtxping [-pport] server_name

where port is the port number on which the client will connect to SQL OpenNet, and server_name is the host name of the SQL OpenNet machine. If no port is specified, the default port specified in the services file is used.

If the network connection is working properly, you’ll receive a “vtxnetd is alive and kicking” message. If there’s a problem, you’ll see an error message. See vtxping utility for more information.

We recommend that you complete the tutorial to ensure that you can connect to a database and to learn more about using xfODBC. See Using the Sample Database As a Tutorial.

xfODBC: stand‑alone access

After installing Connectivity Series, we recommend that you complete the tutorial to ensure that you can connect to a database and to learn more about using xfODBC. See Using the Sample Database As a Tutorial.

sqld program

The sqld program provides the Synergy/DE SQL OpenNet service. It reads opennet.srv and starts the vtxnetd/vtxnet2 server program (see Customizing the opennet.srv file). Sqld also polls vtxnetd/vtxnet2 periodically to verify that the program is still running (see Changing the polling interval). The service name for sqld is SynSQL; the display name is “Synergy/DE OpenNet Server”.

Important

Do not attempt to issue sqld commands from the command line while the Synergy Configuration Program is running.

sqld [‑h] [‑l] [‑q|‑r|‑rs|‑x]

Options

‑h

Display a list of sqld options.

‑l

Log debug information about SynSQL startup in the Windows event log. Used with ‑r or ‑rs.

‑q

Stop the service SynSQL. (See Stopping and removing SQL OpenNet for details on what happens when the service is stopped.)

‑r

Register the service SynSQL.

‑rs

Register the service SynSQL (if necessary) and then start it.

‑x

Unregister (remove) the service SynSQL. If the service is running, ‑x will first stop it.