Examples of Source Configuration Files


This section provides examples of source configuration files that are configured to connect to Microsoft SQL Server and Oracle. Creating a source configuration file to connect to other databases supported by DataDirect XQuery would be similar to these examples. You would need to change the value of the url element. See Sample Connection URIs.

NOTE: If you do not specify a user ID and password in your Java application, you must do so in your source configuration file. The source configuration file examples shown in this section do not specify the user ID and password; therefore, they must be specified in the Java application, as shown in the code example in 3. Developing a Java Application that Executes a Query.

Example 1: Connecting to Microsoft SQL Server

The following source configuration file example shows the minimum you must specify to connect to a Microsoft SQL Server database.

<?xml version="1.0" ?>  
<XQJConnection xmlns="http://www.datadirect.com/xquery">  
  <JDBCConnection prefix="example_connection_name">  
    <url>jdbc:xquery:sqlserver://localhost:1433;DatabaseName=example_db</url>  
    <catalog name="example_db">  
      <schema name="example_db_user"/>  
    </catalog>  
  </JDBCConnection>  
</XQJConnection>  

Example 2: Connecting to Oracle

This second example shows the minimum you must specify to connect to an Oracle database.

<?xml version="1.0" ?>  
<XQJConnection xmlns="http://www.datadirect.com/xquery"> 
  <JDBCConnection prefix="example_connection_name">  
    <url>jdbc:xquery:oracle://localhost:1521;sid=oracle_sid_name</url>  
    <catalog>  
      <schema name="example_db_user"/>  
    </catalog>  
  </JDBCConnection>  
</XQJConnection>  

Example 3: Accessing an XML File and Connecting to Microsoft SQL Server

This third example of a source configuration file shows how to access an XML file and a Microsoft SQL Server database. When accessing XML files, often a relative path is used to locate the file; the baseURI element in this example specifies the relative path.

<?xml version="1.0" ?>  
<XQJConnection xmlns="http://www.datadirect.com/xquery">  
  <baseUri>file:///c:/programs/ddxq/examples/</baseUri>  
  <JDBCConnection prefix="example_connection_name">  
    <url>jdbc:xquery:sqlserver://localhost:1433;DatabaseName=example_db</url>  
    <catalog name="example_db">  
      <schema name="example_db_user"/>  
    </catalog>  
  </JDBCConnection>  
</XQJConnection>