Amazon festival offer

Wednesday, 24 April 2013

Connecting iReport to MS SQL Server


iReport is a report designer for JasperReport server where you can develop the reports , to develop the reports you need to fetch the data from different  data sources like MySQL, Microsoft SQL Server, Oracle etc.
                     iReport supports many different Data source types to provide data for its reports.  One of these Data sources is "Database JDBC connection" which is used to write reports against MySQL.
To add a Data Source click here
                        
      

This will display a list of Datasources . Now to create a datasource click on New button. Select “Database JDBC connection” then press Next button.
                                                                      
Now fill this dailog box :-
Name:-  MySQL daatabase connection (You can give any name)
JDBC Driver:- Select data dabse driver from drop down list.
Server Address:- localhost:3306 (localhost is the host name and  3306 is default MySQL port)
Database:- Database name which you want to connect.
Click on wizard button
Username and Password, Test the datasource and Save.
                                                                  
Now the datasource is created and you can used in iReport for creating reports. To fetch the data from datasource you have to write SQL queries. You can also use Query Designer to write the queries.

Connecting to SQL Server:- Follow the same steps but you may need to download JDBC driver for SQL Server and then add in iReport.

Steps to set the Classpath for iReport:
1) Go to "Tools / Options" menu and select iReport
2) Verify that database JDBC driver is present:
         - Choose "Classpath" tab
         - Click "Add JAR" and then locate the SQL Server driver from drop down list
         - Click "OK"

3) Click "Connections / Datasources" icon in toolbar
5) Click "New" and set up a "Database JDBC Connection" using driver from step 2
6) Click "Test" to verify the data source works correctly
7) Click "Save" to save the data source


In the same way you can connect to any datasource like ORACLE.

No comments: