Creating a Database Connection

Before you can execute a collection() function in an XQuery document, you need to create a database connection. This is part of the process of making the database tables and views available to your XQuery code.

Specific properties vary from database to database, but to connect to a database you typically need to specify

  • The type of database to which you want to connect. You can connect to one of the default relational databases supported by Stylus Studio (Oracle, Microsoft SQL Server, Informix, and so on).
  • The server URL and other connection parameters. In addition to the server's location, connection parameters can include the server name, the port through which the connection is established, and other information, such as a server ID (SID).
  • The username and password required to log in to the database.

This section describes these connection setting properties in greater detail and.

This section covers the following topics:

Choosing a Database

Stylus Studio allows you to connect to any of a number of natively supported relational databases, such as Oracle, Microsoft SQL Server, Sybase, Informix, and IBM DB2.

If you want to connect to one of the relational databases supported by Stylus Studio, simply select the database from the Database Type drop-down list.

Using the Server URL Field

You use the Server URL field to identify the server hosting the database to which you want to connect, the port to use, and any other required or optional parameters. For example, the string used to connect to a Microsoft SQL Server database might look like this:

The specific syntax of the string you enter in the Server URL field varies based on database type. Consult your database documentation for information regarding connectivity syntax and optional parameters.

Tip

 

Stylus Studio populates the Server URL field with a default string appropriate for the database you specify in the Type field.

Username and Password

You use the Username and Password fields to specify the database user you want to associate with this data source.

How to Create a Database Connection

To create a database connection:
1. Display the File Explorer window if it is not already open (View > File Explorer).
2. In the File Explorer window, right-click the RelationalDB icon and select New Server from the short-cut menu.

Stylus Studio displays the Connection Settings dialog box.

Figure 316. Connection Settings Dialog Box

3. Specify the information needed to create the database connection and click OK.

The server connection appears in the File Explorer window.

Figure 317. New Database Server Connection

 
Free Stylus Studio XML Training: