Академический Документы
Профессиональный Документы
Культура Документы
this time i described how make one very simple report. lets
downloadiReport. here i download iReport-3.0.0 zip file. This
version i found mysql driver jar found in the lib folder but i did
not see the oracle(ojdbc14.jar) driver jar file. if you would like
to use oracle please put this jar file into the lib folder.
screen shot
now you get one report. now you can change the report title. it
looks
Now Add Jar button from the right side. Now select
SimpleiReprot project and explore the lib folder and select all
the jar files of lib folder. now click OK. Select Order and Exprot
tab and Select All button from right side. Click OK.
-DBConnector.java
import java.sql.Connection;
import java.sql.DriverManager;
/*
* Database connection class.
* it return single instance of connection
* author: rajib_info@yahoo.com
*/
if (connection != null) {
return connection;
}
try {
Class.forName(org.gjt.mm.mysql.Driver).newInstance();
connection = DriverManager.getConnection(
jdbc:mysql://localhost/development, root, );
} catch (Exception e) {
e.printStackTrace();
}
return connection;
}
}
- SimpleiReport.java
import java.sql.Connection;
import java.util.HashMap;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
/*
* this class generates one pdf file from jaspar file. here i used
one condition that filter
* only first 30 records.
* author: rajib_info@yahoo.com
*/
} catch (JRException e) {
e.printStackTrace();
System.exit(1);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}
- output console