Installing and Running DataDirect XQuery™ ACORD Examples
You can run the examples discussed in XQuery Operation Examples for an ACORD Insurance Application on your own machine. To get started, you need:
- A copy of DataDirect XQuery™ 3.0 or later — either an evaluation copy or a fully licensed DataDirect XQuery™
- Your local or remote Microsoft SQL Server (2000 or later) database
The examples can be modified to be installed and run against different databases, but we have written and tested them against a Microsoft SQL Server database at this point.
Preparing the Database
Before you can run the examples, you need to create and populate the tables in your database. We have prepared two SQL scripts to make this task as easy as possible:
Both scripts assume that you want to create/remove the tables in the pubs database; you can easily change that default at the beginning of the script files.
Running the XQuery Files
The XQuery files described in XQuery Operation Examples for an ACORD Insurance Application are all available in the ACORD-xquery.zip file that you can download and expand on your local file system. Once downloaded, you can run the XQuery files in at least two different ways:
- From a command line
You can execute the sample XQuery files with DataDirect XQuery™ using the following command line template:
>java -jar c:\ddxq3.0\lib\ddxq.jar -jdbc
jdbc:xquery:sqlserver://localhost:1433;databaseName=pubs;user=user;password=pass !indent=yes acord_201.xquery
Make sure you use the proper location for ddxq.jar (depending on where you have installed DataDirect XQuery™) and to set the correct information about server location, database name, and user information. The template command line string shown here assumes the current directory is where the sample .xquery files are located on your local file system. The "!indent=yes" option is not necessary, but it makes the result much easier to read.
If the XQuery requires that a document is bound to an external variable, you can do that from the command line specifying the variable binding:
>java -jar c:\ddxq3.0\lib\ddxq.jar -jdbc
jdbc:xquery:sqlserver://localhost:1433;databaseName=pubs;user=user;password=pass acord_201-extvar.xquery !indent=yes +request="201-1.xml"
- From Stylus Studio
You can run all sample files from the Stylus Studio development environment (http://www.stylusstudio.com). Before being able to do so though, you need to configure the XQuery in Stylus Studio to connect to the proper database; to do so:
- In Stylus Studio File Explorer, right click on the Relational DB entry, and choose New Server.
- Enter the connection information to the server where you have installed tables and data as described earlier.
- Connect to the server and navigate down to the database (pubs, if you chose the default installation) where the data is located.
- Open any sample XQuery, and drag and drop the database (pubs, for example) to the panel to the right of the XQuery text.
- Run the XQuery (click the green arrow at the top of the XQuery Editor or press Ctrl+F5).
Repeat these steps for all XQueries you want to run. Note, however, that once you save them, this information is available next time you open them in Stylus Studio.
About the Java Files
The Java files described in Using DataDirect XQuery™ to Bind External Variables to Dynamic Values can be compiled and run in your preferred Java development environment (and in Stylus Studio). These files are also available in ACORD-xquery.zip.
Note that you will need to edit the top sections of the Java sources to reference the correct folder locations and database connection strings.
In addition, Acord181EJB.java and Acord201.java rely on DataDirect XQuery™. These files need ddxq.jar in your classpath to compile and run. Finally, Acord201JDBC.java and Acord204JDBC.java rely on DataDirect Connect for JDBC and require the proper Connect for JDBC libraries in the classpath to compile and run.

Learn More!
Go to www.xquery.com to learn more about putting DataDirect XQuery™ to work for you today!
