Sunday, April 27, 2008

How to Connect to a Database Or a Data Source using iReport

To connect to a data source using iReport you need to configure the Data source. To do that go to Dataà Connection/Data Sources From the Main Menu items.

You would get the Connection/Data Sources Window. Click “New”

Most of the time you would be using a JDBC data source or a Hibernate Connection. For the sake of the first report we will look at the much simpler and common way of using a JDBC connection. To configure a JDBC connection click “JDBC Connection” and click “Next”

To connect to a MySQL or a Oracle Database first you need to define a Driver. While iReport comes with a lot of dirvers it for some strange reason does not include an Oracle Driver.

Connecting to MySQL

Set your server path and data base name in the JDBC URL Wizard. Then Click Wizard and it will automatically set your JDBC URL. Make Sure you have selected the com.mysql.jdbc.Driver and Type the User name and password to the database and click Test.

Your Data base connection should be working properly. If not check your MySQL database URL is correct or/and the database server is running properly. If the test is Successful click Save.

Connecting to Oracle Database.

As I mentioned above iReport does not have a Oracle JDBC driver included. To Connect to Oracle you need to have a Oracle JDBC Driver compliant with your Oracle Version. They can be found here. I’ve used ojdbc14.jar with Oracle 9i and 10i.

Place the Oracle JDBC Driver in your lib directory. If you have installed using the default settings this would be in the c:/Programfiles/jaspersoft/ireport2.0.5 directory

Set your Server Path and the database name in the JDBC URL wizard. Then click “Wizard” button and the Database URL would be set WITH THE PORT 1521. If you are not using that simply modify it to the port u are using in the JDBC URL Field. Type the User name and password to the database.

Set the JDBC Driver Field to “oracle.jdbc.driver.OracleDriver” and click test. If not successful check your username/password and Database URL and Try again. After the test is successful click Save.

Now you are ready to start designing a report.

UPDATE on 08 Dec 2010

A Better Example Through Comments (@author prakash)

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 mysql.jdbc.Driver
- 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


48 comments:

Anonymous said...

Hi,

I've placed ojdbc14.jar and classes12.jar into ireport lib directory. but i still can't connect to the database. sometimes it told: network adapter can't establish connection. sometimes: connection refused. could you help me, please?

Thanks.

Ika

sharing shoulder said...

how can i connect sql server.. pls anyone tell me..

Anonymous said...

I too am trying to connect with SQL Server

My recommendation is that this should be included with the release package jDBC?, MS JDBC Driver ?

All this talk of Ants, TomCats and Jakarta is just confusing me :)

I downloaded
http://freefr.dl.sourceforge.net/sourceforge/jtds/jtds-1.2.2-dist.zip

Installed this into a folder & it worked OK for me specifying server / port/ db (my Port was 1434)

Good luck !

Anonymous said...

How to connect ireport using postgressgl pls helpppppppppppppppppppppppp,,,,,,,,,,,,

Anonymous said...

please in the above article, you have referred to only JDBC connection, please write something about how to create hibernate connection

Anonymous said...

is ireport connect remotly with database i try but i failed can any one help me
thanks;

prakash said...

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 mysql.jdbc.Driver
- 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

Anonymous said...

the step on prakash said... on January 12, 2010 worked!

Anonymous said...

Thanks prakash. It was very useful information. Acromantula, please remove your explanations on how to connect to a database with ireport and expand prakash's idea because it's clearly more intuitive.

Anonymous said...

Thanks it is useful but during test for database connection i am getting nested exception. what does it mean?

Anonymous said...

i tried classe12.jar ojdbc6.jar

no way to connect to an oracle database (8.1.7)

venu said...

How to connect the spring hybernate .step by step explain

Anonymous said...

How to connect netezza database through i report

Anonymous said...

to get connection to oracle 8.1.7 works put just the classe12.jar and drop ojdbc6.jar from /tomcat/lib

it works for me

bye

Anonymous said...

Sres. Yo tuve este problema por mucho tiempo, sin lograr resolverlo. Pero el día de hoy, desinstale el iReport y lo volvi a instalar, a la primera funciono, momento despues configure otras cosas y mi sorpresa...!!! dejo de funcionar nuevamente. Retrocediendo con lo que habia echo, despues de la instalación me di cuenta que al configurarle el proxy manualmente al iReport, deja de resolver la direccion del server de BD (Ip o hostname). Solo le quite el proxy nuevamente y tengo una conexión estable. Por si a alguien le sirve esta solucion.

Anonymous said...

i still dont get it.. how to connect to sql developer?

Anonymous said...

How can I add new driver to connect to HiRDB .how can I configure it

Anonymous said...

Hi,

When i try to establish an oracle connection having a service name as opposed to a SID iReportDesigner is throwing invalid connection format error.
Can you please tell me how to get around this?

Many Thanks in advance,
Manju

as said...

hello sir,
I done all the things that u told but while connecting to database i got error

SQL problems: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
jdbc:oracle:thin:@localhost:1521:EMPLOYEES
plz help me.

Anonymous said...

Thanks°°°

Tarun said...

Thnx ....Its working...

Unknown said...
This comment has been removed by the author.
Anonymous said...

Hi, please how can I connect iReports to a remote mysql database, please help

Anonymous said...

Thank You very much for this article
-Shrikant Pande

abc said...

SQL problems: The Network Adapter could not establish the connection
jdbc:oracle:thin:@localhost:1521:thacam

m getting above error ...can u help?

Anonymous said...

i just want to ask if, do i need to have an internet connection while performing the connection on database?? thankyou and godbless ^_^

Unknown said...

java.sql.sqlexception io exception the network adapter could not establish the connection oracle 10g

Anonymous said...

how to automatically refresh the data from database to ireport

Anonymous said...

Thanks for your post, you made my day!!

sfloyd said...

Oracle 11.2.0.2.0 Connection finally worked by following the suggested steps above and slightly modifying the value in the "JDBC URL" field for iReport 4.0.1:

Steps to set the Classpath for iReport AND Modify the JDBC URL:
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 correct driver
(jar file, I used ojdbc6_g.jar)
- Click "OK"
3) click "Connections / Datasources" icon in toolbar
4) click "New" and set up a "Database JDBC Connection"
5) JDBC Driver - In the Drop Down, Select "Oracle (oracle.jdbc.driver.OracleDriver)
6) JDBC URL - populates with default value for the URL (Skip This Field for Now)
7) Server Address - Enter host name [srcoux00.mydomain]
8) Database - Enter database name [MyDevDatabase]
9) click the "Wizard" Button - Replaces JDBC URL field with new contents (values entered in steps 7,8)
10) In the JDBC URL field, change the last ":" to a "/"
Ex: jdbc:oracle:thin:@srcoux00.mydomain:1521/MyDevDatabase
11) Username - Enter username
12) click "Test" and enter password, to verify the data source works correctly
13) click "Save" to save the data source


Radha said...

oidbc is not working plz give me solution for that

Radha said...

ojdbc6 is not working

Thang David said...

Oracle : The Network Adapter could not establish the connection . Help

Thang David said...
This comment has been removed by the author.
Unknown said...

The most effective method to Find Oracle Database Connection Details with Remote DBA Services
Well! In the event that you are new on Oracle Database and in the event that you make another association through SQL designer however in the event that you are not ready to get the association points of interest, have name and port at that point rapidly contact to Database Administration for Oracle or Online Oracle DB Support. Aside from that on the off chance that you have any issue with respect to Oracle like association issue, establishment issue, arrangement issue et cetera then you can likewise contact to our Oracle Database Solution and experience the best help through most recent innovation.
For More Info: https://cognegicsystems.com/
Contact Number: 1-800-450-8670
Email Address- info@cognegicsystems.com
Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

Unknown said...

How to Connect Oracle Database in PHP? Contact to Remote DBA Service
For a new user surely it becomes impossible to connect Oracle Database in PHP because it requires lots of skills. However, being a best support provider Cognegic offer Database Administration for Oracle and Online Oracle DB Support for those users who want to connect their Oracle Database in PHP. Here our experts consistent tracking the entire database operations and prevent the problems before they happen. With Oracle Database Solution we enhance the productivity and allow you to dedicate your resource to different areas of business.
For More Info: https://cognegicsystems.com/
Contact Number: 1-800-450-8670
Email Address- info@cognegicsystems.com
Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

Unknown said...

How to solve if you are not able to Configure Oracle 11g net server? Contact to DB Installation Support
Whenever you install Oracle 11g in your Windows server 2008 and once you try to configure Oracle net server with the port number 1521 then suddenly you get an message which intimates that “Use other port this port is already user” then how will you tackle this problem? If you are new user then surely you spend lots of money to any support company but still you do not whether your will solve or not. But with Cognegic’s DB Installation and Configuration Support or DB Configuration Support you can easily your problem.
For More Info: https://cognegicsystems.com/
Contact Number: 1-800-450-8670
Email Address- info@cognegicsystems.com
Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

Unknown said...

How to Solve PostgreSQL Configuration Issue in SQL Developer? Contact to Postgres SQL Support for Windows
If you are unable to solve PostgreSQL configuration issue in SQL developer then quickly contact to Cognegic’s Postgres SQL Support for Linux or PostgreSQL Relational Database Service to fetch the best solution regarding configuration. There are several reasons why clients choose our premium support as compared to other support because we provide easy and quick service within estimated time period. Here we also provide PostgreSQL Remote Database Service and easily solve your all technical issue.
For More Info: https://cognegicsystems.com/
Contact Number: 1-800-450-8670
Email Address- info@cognegicsystems.com
Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

moshrabbi121 said...

I’m impressed, I need to say. Actually rarely do I encounter a blog that’s each educative and entertaining, and let me let you know, you will have hit the nail on the head. Your idea is outstanding; the issue is something that not enough persons are speaking intelligently about. I am very joyful that I stumbled throughout this in my seek for something relating to this. casino slots

Unknown said...

Solve Postgres Database Encoding Problem with to Postgres SQL Support for Linux

Rapidly investigate your Postgres database encoding issue with Cognegic's Postgres SQL Support for Windows or PostgreSQL Relational Database Service. The essential capacity of Postgres is to store information commonly however once this encoding issue is emerge then it progresses toward becoming to deal with your Postgres condition. To determine this issue we give helpful help which is under in your financial plan. In this way, specifically contact to our specialized specialists and investigate the propel bolster

For More Info: https://cognegicsystems.com/
Contact Number: 1-800-450-8670
Email Address- info@cognegicsystems.com
Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

Unknown said...

How to Solve Postgres Database Encoding Problem? Contact to Postgres SQL Support for Linux

Rapidly look at your Postgres database encoding issue with Cognegic's Postgres SQL Support for Windows or PostgreSQL Relational Database Service. The central furthest traverses of Postgres is to store information customarily yet once this encoding issue is rise then it pushes toward convincing the opportunity to be to deal with your Postgres condition. To pick this issue we give strong help which is under in your fiscal game plan. Thusly, oversee contact to our particular administrators and look at the actuate bolster.

For More Info: https://cognegicsystems.com/
Contact Number: 1-800-450-8670
Email Address- info@cognegicsystems.com
Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

Unknown said...

How would I troubleshoot my Installation Issue through Cognegic's DB Installation Support?

At Cognegic we ensure the secured and productive foundation of your entire database. We are ace in the foundation of different kind of databases including MySQL Database, Oracle database, MongoDB, Cassandra database, MS SQL Server and whatnot. Pick our first class DB Configuration Support and Database Management Services to decide your worry. We have profoundly gifted and confirmed specialized specialists who offer help and help 24*7. Cognegic's primary aphorism is to comprehend your issue by giving development bolster and to that reason we accessible all the time in your administration.

For More Info: https://cognegicsystems.com/
Contact Number: 1-800-450-8670
Email Address- info@cognegicsystems.com
Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

Anonymous said...

thank you

kingvincent said...

Hello All,
Thanks for all the contributions. In my case after carrying out the steps, i was still getting ora-28040 no matching authentication protocol.
I gave up. I decided to try restarting the iReport and retry test connection. It worked!!!

erection pills viagra online said...

I get pleasure from, lead to I found just what I used to be looking for. You have ended my 4 day lengthy hunt! God Bless you man. Have a great day. Bye

Rasa Soft said...

Thanks alot bro!

Anonymous said...

1XBet
Betting in India. It www.jtmhub.com can be great to find the most popular brands, especially ones that offer betting on sports 1xbet app such as football, tennis,  Rating: gri-go.com 1/10 · ‎Review by Riku VihreasaariWhere https://deccasino.com/review/merit-casino/ can I find 1xbet?Where can I find 1xbet betting?

Alis said...

Useful tutorial

Post a Comment