Description
I want to connect to sql server database, download the drivers and place the jbdc statement but it still does not work, it throws me this error:
Fatal error: Uncaught PHPJasper\Exception\ErrorCommandExecutable: Your report has an error and couldn 't be processed!\ Try to output the command using the function
output();
and run it manually in the console. in C:\xampp\htdocs\som\vendor\geekcom\phpjasper\src\PHPJasper.php:219 Stack trace: #0 C:\xampp\htdocs\som\src\Examples.php(102): PHPJasper\PHPJasper->execute() #1 C:\xampp\htdocs\som\pdfgenerate.php(12): Examples\Examples->DbExample() #2 {main} thrown in C:\xampp\htdocs\som\vendor\geekcom\phpjasper\src\PHPJasper.php on line 219
Function to execute:
public function DbExample()
{
$input = __DIR__ . '/input/sample.jrxml';//teste.jrxml
$output = __DIR__ . '/output';
$jdbc_dir = __DIR__ . '/vendor/geekcom/phpjasper/bin/jaspertarter/jdbc';
$options = [
'format' => ['pdf', 'xml', 'html'],
'locale' => 'en',
'params' => ['Parameter' => '1'],
'db_connection' => [
'driver' => 'generic', //mysql, postgres, oracle, generic (jdbc)
'username' => 'testadmin',
'password' => 'root',
'host' => 'server_fma',
'database' => 'employee',
'port' => '1433',//1433 sql server connect
'jdbc_driver' => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
'jdbc_url' => 'jdbc:sqlserver://server_fma:1433;databaseName=employee',
'jdbc_dir' => $jdbc_dir
]
];
echo $this->PHPJasper->process(
$input,
$output,
$options
)->execute();//execute
// exec($jasper->output().' 2>&1', $output);
// print_r($output);
}
the test was done in jrxml and the connection to the database works without problem.