Jump to content
We've recently updated our Privacy Statement, available here ×

Integrate jaspereport with php and JDBC connexion to AS400


mostafacasa

Recommended Posts

Hello,

I want to edit report from php using Javabridge with AS400 on server Zend , this is the code that u have foudn in the net for windwos but isnt work on zend ?!

I have create one report and test it on Jasperreport with JDBC its work fin but i dont know how integrate it on php ?

Plaise if someone can help me


NB : I have this version of Javabridge on ZendServer :

 

JavaBridge Server Enabled
JavaBridge extension version 3.1.21
JavaBridge Server Port 10002
JavaBridge Ints are Longs No
JavaBridge Encoding UTF-8
JavaBridge Use Java Objects No

 

Code:
<?php               $reportsPath ="/../../Raport/";        $reportFileName = "report1";        $jasperReportsLib = "/../../Raport/";            if(extension_loaded('java')) {                   // lecture du répertoire où sont rengés les librairies utiles à JasperReports            $handle = @opendir($jasperReportsLib);                           // ajout de tous les fichier jar au chemin de classe (Class Path)            while(($new_item = readdir($handle))!==false) {                               $java_library_path .= 'file:'.$jasperReportsLib.'/'.$new_item .';';            }                          try {                // chargement des librairies au classpath                java_require($java_library_path);                       // création de la connexion JDBC                $Conn = new Java("org.altic.jasperReports.JdbcConnection");                // driver                       $Conn->setDriver("sun.jdbc.odbc.JdbcOdbcDriver");                // url de connexion                $Conn->setConnectString("jdbc:odbc:D6075e50");                // utilisateur                $Conn->setUser("mustapha");                // mot de passe                $Conn->setPassword("azerty");                       // Compilation du fichier JRXML en fichier Jasper                       $sJcm = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager");                $report = $sJcm->compileReport($reportsPath .$reportFileName.".jrxml");                       // Remplir le modèle avec les données                       $sJfm = new JavaClass("net.sf.jasperreports.engine.JasperFillManager");                $print = $sJfm->fillReport(                       $report,                new Java("java.util.HashMap"),                $Conn->getConnection()                );                       // Export du fichier au format pdf                $sJem = new JavaClass("net.sf.jasperreports.engine.JasperExportManager");                $sJem->exportReportToPdfFile($print, $reportsPath .$reportFileName.".pdf");                       if (file_exists($reportsPath .$reportFileName.".pdf")){                     header('Content-disposition: attachment; filename="'.$reportFileName.'.pdf"');                     header('Content-Type: application/pdf');                     header('Content-Transfer-Encoding: binary');                     header('Content-Length: '. @filesize($reportsPath . $reportFileName.".pdf"));                     header('Pragma: no-cache');                     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');                     header('Expires: 0');                     set_time_limit(0);                     @readfile($reportsPath .$reportFileName.".pdf") or die("problem occurs.");                 }                   } catch (JavaException $ex) {                 $trace = new Java("java.io.ByteArrayOutputStream");                $ex->printStackTrace(new Java("java.io.PrintStream", $trace));                print "java stack trace: $trace\n";            }        }                      ?>
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...