Connecting to SQL Servers

All SQL servers require that some type of connection be established between a client program and the server before any database operations can be attempted. In Zim, a connection between a Zim application and an SQL server is established by the "CONNECT" command and removed by the "DISCONNECT" command.

During the execution of any Zim application, a CONNECT command must have been executed prior to the execution of any Zim command requiring database operations to be performed by the SQL server. Connections can be multiple or single as explained below.

Single Connections

When SQL database servers are accessed one at a time, a connection is always followed by a disconnection. Example:

connect to "JDBCSAM" using ("SalesDB", "sqlserver", "admin", "", "1422", "172.16.20.33")

...

disconnect from "JDBCSAM"

...

connect to "JDBCSAM" using ("Marketing", "oracle", "scott", "tiger", "1501", "www.mycompany.com")

...

disconnect from "JDBCSAM"

...

Notice that each CONNECT statement is followed by a DISCONNECT statement. In the above example, the first connection is different from the second one but it can be the same as well.

Multiple or Concurrent Connections

In this scenario, more than one connection is established and maintained at the same time without an intervening disconnection:

connect to "JDBCSAM" using ("SalesDB", "sqlserver", "admin", "", "1422", "172.16.20.33")

connect to "MYJDBC" using ("Marketing", "oracle", "scott", "tiger", "1501", "www.mycompany.com")

...

disconnect from "MYJDBC"

disconnect from "JDBCSAM"

Now, the second connection is performed not to JDBCSAM anymore but an alias to it called MYJDBC. The reasoning behind this difference is that all ZIM objects need to reference a specific type of object (for Entity Sets, it is the EntType; for Relationships, it is the RelType and so on) and Zim needs to know which object belongs to each type.

The aliases are defined in the "zimalias.zim" configuration file as described in the Servers Alias Configuration File.

Obviously, an alias could have been used in the example for single connections as well.