You are on page 1of 7

Use a Sql Server Datasource from Java

This document shows how to create a simple program with Sql Server as the datasource used to
create a report using Windward Reports. To keep it very simple it creates a command line
application. The sample here is created using IntelliJ running on Windows XP.
1. Download the Sql Server JDBC driver.
a. The driver for Sql Server 2000 and 2005 is at
http://www.microsoft.com/downloads/details.aspx?familyid=e22bc83b-32ff-
4474-a44a-22b6ae2c4e17&displaylang=en. This driver is good for both Sql
Server 2000 and Sql Server 2005. It is available as both an exe (Windows install)
and .tar.gz (unix install).
If you want the Sql Server 2000 JDBC driver, the latest version is at
http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-
461A-B138-2AA54BFDC03A&displaylang=en.
b. Click Download:
c. We are running on Windows so click “…want to download the Microsoft
Windows…” link

d. Save the download and the run it. You will then be asked for the file to unzip to.
You should add the root directory you want this installed to to the default folder
which is just “Microsoft SQL Server 2005 JDBC Driver” (I added c:\net\). Then
click Unzip.

e. To access Sql Server, we need C:\net\Microsoft SQL Server 2005 JDBC


Driver\sqljdbc_1.0\enu\sqljdbc.jar in our classpath. Remember that the c:\net part
is what I set – your root directory is probably different. For the example here we
will be accessing the Northwind database running on Sql Server 2000.
2. Create a new project using your IDE. Here is the project after it was created in IntelliJ
and a single class is created with a main method.

3. Add all of the Windward Reports jar files to the libraries for this project. These are found
in c:\Program Files\Windward Studios\Windward Reports Java Engine\lib if you installed
to the default directory when installing Windward Reports.
And we need to add the jar file for Sql Server.

4. Copy the template from C:\Program Files\Windward Studios\Windward Reports Java


Engine\samples\sample12 to the directory with the sample report.
to

5. You also need to copy WindwardReports.properties to this directory.

6. To keep things simple, there is no error checking and this will always create a PDF
report. To see a complete version of this simple approach, please look at RunReport.java
in sample 1.
7. Passing templates to the engine and getting the created report back is all done withCsee7 Tc -0.0007 Tw -