<?php define('JAVA_INC_URL', 'http://localhost:85/JavaBridge/java/Java.inc'); require_once JAVA_INC_URL; //require_once("http://127.0.0.1:85/JavaBridge/java/Java.inc"); $system = new Java('java.lang.System'); $class = new JavaClass("java.lang.Class"); $class->forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //$class->forName("com.mysql.jdbc.Driver"); $driverManager = new JavaClass("java.sql.DriverManager"); //$conn = $driverManager->getConnection("jdbc:mysql://localhost/stdb?user=sa&password=Tamakogi2012"); $conn = $driverManager->getConnection("jdbc:sqlserver://127.0.0.1;databaseName=st;user=sa;password=Tamakogi2012"); //compliler $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); $viewer = new JavaClass("net.sf.jasperreports.view.JasperViewer"); $report = $compileManager->compileReport("C:/inetpub/wwwroot/inv_01.jrxml"); //fill $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); $params = new Java("java.util.HashMap"); //$params->put("text", "Text"); $params->put("ofYear", 2015.0); //$params->put("date", convertValue("2007-12-31 0:0:0", "java.sql.Timestamp")); $emptyDatasource = new JavaClass("net.sf.jasperreports.engine.JREmptyDataSource"); $jasperPrint = $fillManager->fillReport($report, $params, $conn); $exportManager = new JavaClass("net.sf.jasperreports.engine.JasperExportManager"); $outputPath = realpath(".") . "/" . "output.pdf"; //$exportManager->exportReportToHtml($jasperPrint,$outputPath); //header("Content-type: application/html"); $exportManager->exportReportToPdfFile($jasperPrint, $outputPath); header("Content-type: application/pdf"); readfile($outputPath);
#!/usr/bin/php <?php // // this test must be called twice with a standalone or J2EE back end // include_once "java/Java.inc"; $rc = false; for ($i = 0; $i < 100; $i++) { @java_reset(); $here = getcwd(); java_require("{$here}/arrayToString.jar"); $Thread = new JavaClass("java.lang.Thread"); $loader = $Thread->currentThread()->getContextClassLoader(); $Class = new JavaClass("java.lang.Class"); $class = $Class->forName("ArrayToString", false, $loader); $class2 = $loader->loadClass("ArrayToString"); $System = new JavaClass("java.lang.System"); $hc1 = java_values($System->identityHashCode($class)); $hc2 = java_values($System->identityHashCode($class2)); $rc = $hc1 == $hc2; if (!$rc) { $Util = new JavaClass("php.java.bridge.Util"); $vm_name = $Util->VM_NAME; echo "ERROR: {$hc1}, {$hc2}\n"; echo "Dynamic loading not available in this VM.\n"; echo "Responsible VM: {$vm_name}\n"; break; } } if ($rc) {
public function report_TRN1I060() { $get_data = $this->input->get(NULL, TRUE); if (empty($get_data) === FALSE) { $this->checkJavaExtension(); $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); // $report = $compileManager->compileReport("C:/DPE/apache-tomcat-6.0.32/reports/TRN1I040_Regis_v2.jrxml"); $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); // Add parameters // p_termId // p_historyNoStart // p_historyNoEnd $params = new Java("java.util.HashMap"); $str_term_id = (string) $get_data['TERM_GEN']; $params->put("p_termId", $str_term_id); if ($get_data['HISTORY_NO'] === '1') { $str_history_no_start = (string) $get_data['HISTORY_NO_START']; $params->put("p_historyNoStart", $str_history_no_start); $str_history_no_end = (string) $get_data['HISTORY_NO_END']; $params->put("p_historyNoEnd", $str_history_no_end); } $class = new JavaClass("java.lang.Class"); $class->forName("oracle.jdbc.driver.OracleDriver"); $driverManager = new JavaClass("java.sql.DriverManager"); $conn = $driverManager->getConnection("jdbc:oracle:thin:@192.168.2.13:1521:OSRDDB2", "train", "train"); // $emptyDataSource = new Java("net.sf.jasperreports.engine.JREmptyDataSource"); // $jasperPrint = $fillManager->fillReport($report, $params, $conn); $report_name = ''; if ($get_data['REPORT_TYPE'] === 'vertical') { $report_name = 'TRN1I060_Certifys_Vertical.jasper'; } else { if ($get_data['REPORT_TYPE'] === 'horizontal') { $report_name = 'TRN1I060_Certifys.jasper'; } } $jasperPrint = $fillManager->fillReport("C:/DPE/apache-tomcat-6.0.32/reports/" . $report_name, $params, $conn); $filename = uniqid('Report_'); $outputPath = "E:/dd/" . "{$filename}.pdf"; $exportManager = new JavaClass("net.sf.jasperreports.engine.JasperExportManager"); $exportManager->exportReportToPdfFile($jasperPrint, $outputPath); header("Content-type: application/pdf"); readfile($outputPath); unlink($outputPath); } }
function reporte($id = null) { require_once "http://localhost:8080/JavaBridge/java/Java.inc"; $parteId = $id; $params = new Java("java.util.HashMap"); $params->put("parteid", $parteId); try { $jasperxml = new java("net.sf.jasperreports.engine.xml.JRXmlLoader"); $jasperDesign = $jasperxml->load(realpath("InformedePartes.jrxml")); $query = new java("net.sf.jasperreports.engine.design.JRDesignQuery"); $query->setText("select u.username, p.* ,t.inicial as tinicial, t.final as tfinal, t.entrada as tentrada, t.salida as tsalida,\n\t\t\t\t\t\t\tr.inicial as rinicial, r.final as rfinal, r.entrada as rentrada, r.salida as rsalida,\n\t\t\t\t\t\t\te.inicial as einicial, e.final as efinal,\n\t\t\t\t\t\t\te2.entrada as eeentrada, e2.salida as eesalida, e2.inicial as eeinicial, e2.final as eefinal\n\t\t\t\t\t\tfrom partes p , textos t ,reales r , enteros e, enteros e2, users u\n\t\t\t\t\t\twhere p.id=t.parte_id and p.id=r.parte_id and p.id=e.parte_id and p.id=e2.parte_id and p.id={$parteId}\n\t\t\t\t\t\tand e.tipocampos_tipoparte_id=2 and e2.tipocampos_tipoparte_id=6 and u.id=p.usuariovendedor;"); $jasperDesign->setQuery($query); $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); $report = $compileManager->compileReport($jasperDesign); } catch (JavaException $ex) { echo $ex; } $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); $class = new JavaClass("java.lang.Class"); $class->forName("com.mysql.jdbc.Driver"); $driverManager = new JavaClass("java.sql.DriverManager"); //db username and password $conn = $driverManager->getConnection("jdbc:mysql://localhost:3306/estacion?zeroDateTimeBehavior=convertToNull", "root", ""); $jasperPrint = $fillManager->fillReport($report, $params, $conn); $exporter = new java("net.sf.jasperreports.engine.JRExporter"); $outputPath = realpath(".") . "\\" . "InformedePartes.pdf"; $exporter = new java("net.sf.jasperreports.engine.export.JRPdfExporter"); $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint); $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath); header("Content-type: application/pdf"); header("Content-Disposition: attachment; filename=InformedePartes.pdf"); $exporter->exportReport(); readfile($outputPath); unlink($outputPath); }
function connect() { //db username and password $host = 'localhost:3306'; $dbname = 'zakila'; $username = '******'; $password = ''; $report = $this->compileReporte(); $fillManager = new \JavaClass("net.sf.jasperreports.engine.JasperFillManager"); $params = new \Java("java.util.HashMap"); $params->put("REPORT_LOCALE", $this->convertValue("en_US", "java.util.Locale")); if (!empty($this->parametros)) { foreach ($this->parametros as $key => $value) { $params->put($key, $value); } } $class = new \JavaClass("java.lang.Class"); $class->forName("com.mysql.jdbc.Driver"); $driverManager = new \JavaClass("java.sql.DriverManager"); try { $conn = $driverManager->getConnection("jdbc:mysql://{$host}/{$dbname}?zeroDateTimeBehavior=convertToNull", $username, $password); $jasperPrint = $fillManager->fillReport($report, $params, $conn); } catch (\JavaException $ex) { echo $ex->getCause(); } $this->jasperPrint = $jasperPrint; }
function reporte() { require_once "http://localhost:8080/JavaBridge/java/Java.inc"; try { $jasperxml = new java("net.sf.jasperreports.engine.xml.JRXmlLoader"); $jasperDesign = $jasperxml->load(realpath("InformedeUsuarios.jrxml")); $query = new java("net.sf.jasperreports.engine.design.JRDesignQuery"); $query->setText("select users.*, roles.name\n\t\t\t\t\tfrom users INNER JOIN roles ON users.role_id=roles.id"); $jasperDesign->setQuery($query); $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); $report = $compileManager->compileReport($jasperDesign); } catch (JavaException $ex) { echo $ex; } $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); $params = new Java("java.util.HashMap"); $params->put("title", "Customer"); $class = new JavaClass("java.lang.Class"); $class->forName("com.mysql.jdbc.Driver"); $driverManager = new JavaClass("java.sql.DriverManager"); //db username and password $conn = $driverManager->getConnection("jdbc:mysql://localhost:3306/estacion?zeroDateTimeBehavior=convertToNull", "root", ""); $jasperPrint = $fillManager->fillReport($report, $params, $conn); $exporter = new java("net.sf.jasperreports.engine.JRExporter"); $outputPath = realpath(".") . "\\" . "InformedeUsuarios.pdf"; $exporter = new java("net.sf.jasperreports.engine.export.JRPdfExporter"); $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint); $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath); header("Content-type: application/pdf"); header("Content-Disposition: attachment; filename=InformedeUsuarios.pdf"); $exporter->exportReport(); readfile($outputPath); unlink($outputPath); }