Pages

How to Create Database Connection and Connect iReport to Database in Netbeans IDE

Jasper Report provides rich facilities for designing and generating reports for java applications. We can design the report in two ways, by using xml or by using visual tools like iReport. We can install iReport as a independent application or integrate it with the IDE like Netbeans and eclipse. In most of the cases we retrieve data from the database, for that we need to create database connection. iReport comes with different database drivers by default which make easy to consider on the designing and viewing the result of our design. In some cases we need to create database connection. In this post we are talking about creating database connection for MS SQL Server in Netbeans. Follow the following steps to create database connection and use it for generating and viewing report in iReport.

Creating Database Connection.
1. First download Microsoft's JDBC Driver and extract it.
2. Go to Services on your left toolbar on Netbeans.
3. Click on Database and create New Connection.

fig: 1

4. Click on New Driver then new window will open and click on Add.

fig: 2

fig: 3

5. Select sqljdbc4 and open it and fill up the required field. Give your database name, username and password.

fig: 4

fig: 5

6. Test Connection and select Next.

fig: 6

7. Select Schema and click on Next.

fig: 7

fig: 8

6. You can see the new database driver on your left toolbar.

fig: 9

Connecting iReport to your Database
7. Click on Report Datasource icon on your top right Netbeans window.

fig: 10

8. Click on New and Select Netbeans Database JDBC Connection.

fig: 11

fig: 12

9. Select Connection and give connection Name.

fig: 13

10. Click on Test to insure database connection is successful and Save.

fig: 14

11. Check the created connection to use it by default on your iReport design.

fig: 15

Now you can use your database, retrieve data and display them on your report from the database.













@msucil

Phasellus facilisis convallis metus, ut imperdiet augue auctor nec. Duis at velit id augue lobortis porta. Sed varius, enim accumsan aliquam tincidunt, tortor urna vulputate quam, eget finibus urna est in augue.

No comments:

Post a Comment