phpjasper-laravel icon indicating copy to clipboard operation
phpjasper-laravel copied to clipboard

Error Connecting to database

Open techkimchhay opened this issue 6 years ago • 4 comments

I am trying to connect to database but get an error like this

`C:\wamp64\www\smb-report\vendor\geekcom\phpjasper-laravel\src\PHPJasper.php /** * @param bool $user * @return mixed * @throws Exception\InvalidCommandExecutable * @throws Exception\InvalidResourceDirectory * @throws Exception\ErrorCommandExecutable */ public function execute($user = false) { $this->validateExecute(); $this->addUserToCommand($user);

    $output = [];
    $returnVar = 0;

    chdir($this->pathExecutable);
    exec($this->command, $output, $returnVar);
    if ($returnVar !== 0) {
        //throw new \PHPJasper\Exception\ErrorCommandExecutable();
        throw new \Exception("{$output[0]}", 1);
    }

    return $output;
}

/**
 * @return string
 */
public function output()
{
    return $this->command;
}

/**
 * @param $user
 */
protected function addUserToCommand($user)
{
    if ($user && !$this->windows) {
        $this->command = 'su -u ' . $user . " -c \"" . $this->command . "\"";

Arguments "usage: jasperstarter process [-h] -f [ ...] [-o ] [-w]"`

and here is my config

` public function generate() { //$input = DIR . '/vendor/geekcom/phpjasper/examples/hello_world.jasper';
$input = base_path('/vendor/geekcom/phpjasper-laravel/examples/Database.jasper');
$output = base_path('/vendor/geekcom/phpjasper-laravel/examples');

    $options = [
        'format' => ['pdf'],
        'locale' => 'en',
        'db_connection' => [
            'driver' => 'mysql',
            'username' => 'root',
            'password' => '',
            'host' => '127.0.0.1',
            'database' => 'smb',
            'port' => '3306'
        ]
    ];

    $jasper = new PHPJasper;

    $jasper->process(
        $input,
        $output,
        $options
    )->execute();
    return view('welcome');
}`

could you please help to tell what's went wrong?

techkimchhay avatar May 06 '18 09:05 techkimchhay

Good afternoon, I have the same or similar mistake usage: jasperstarter process [-h] -f <fmt> [<fmt> ...] [-o <output>] [-w] Help, please

jorgeescobar avatar May 30 '18 21:05 jorgeescobar

with this code the error does not come out anymore, but the fields in the report come out as NULL $jasper->process( $input, $output, array('pdf', 'rtf'), array('php_version' => phpversion()), array( 'driver' => 'mysql', 'username' => 'root' 'password' => '', 'host' => 'localhost', 'database' => 'ksoftdb', 'port' => '3306',) )->execute(); help please...

jorgeescobar avatar Jun 01 '18 13:06 jorgeescobar

Please check the parameters of your DB

geekcom avatar Jun 27 '18 11:06 geekcom

You missing , (comma) after username root. in connection array.

sfdsfdsfdesfdsghefasefs avatar May 23 '19 12:05 sfdsfdsfdesfdsghefasefs