Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem to connect in mysql database with jdbc #7

Open
fabriciomesser opened this issue Sep 12, 2018 · 6 comments
Open

Problem to connect in mysql database with jdbc #7

fabriciomesser opened this issue Sep 12, 2018 · 6 comments

Comments

@fabriciomesser
Copy link

Good afternoon!

My name is Fabrício Messer and i has many problems to connnect in my database by jasperstarter and i ask for your help.

ps: I use the client provided by you and without connection it works perfectly.

When i pass my db-url, include queryStrings to solved timezone and SSL problems, but the javastarter dont recognized this commands.

I define my connect using the command:

Route::get('/myroute', function () {

$output = public_path() . '/reports/'.time().'_myReport';
$report = new JasperPHP;

// $report->compile(public_path() . 'myreport.jrxml')->execute();
$database = [
'driver' => env('DB_CONNECTION'),
'host' => env('DB_HOST'),
'port' => env('DB_PORT'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'database' => env('DB_DATABASE'),
'jdbc_driver' => 'mysql-connector-java-8.0.12.jar',
'jdbc_url' => 'jdbc:mysql://localhost:3306/databasename?useTimezone=true&useSSL=false&useTimezone=true&serverTimezone=UTC',
'jdbc_dir' => base_path() . env('JDBC_DIR', '\vendor\copam\phpjasper\src\JasperStarter\jdbc')
];
$report->process(
public_path() . 'myreport.jrxml',
false,
array('pdf'),
array(),
$database
)->execute();
});

That result in jasperstarter command:

"jasperstarter --locale pt_BR process "myreport.jrxml" -f pdf -t mysql -u root -p dbpassword -H 127.0.0.1 -n db --db-port 3306 --db-driver mysql-connector-java-8.0.12.jar --db-url jdbc:mysql://localhost:3306/databasename?useTimezone=true&useSSL=false&useTimezone=true&serverTimezone=UTC --jdbc-dir C:\xampp\htdocs\segafb-laravel\vendor\copam\phpjasper\src\JasperStarter\jdbc "

I get the answer

Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Wed Sep 12 11:52:47 BRT 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Unable to connect to database: The server time zone value 'Hora oficial do Brasil' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
'useSSL' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
'useTimezone' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
'serverTimezone' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.

Can you help me?

Sorry if my question and my bad english , but i've been a developer for three months.

Thanks for listening.

@jeffbarretocopam
Copy link
Contributor

Please check this params

'jdbc_driver': 'com.mysql.cj.jdbc.Driver',
'jdbc_url': 'jdbc:mysql://localhost:3306/databasename?useTimezone=true&useSSL=false&useTimezone=true&serverTimezone=UTC',
'jdbc_dir': '../' #Location where the connection driver jar is located

Make sure your path is correct

@fabriciomesser
Copy link
Author

fabriciomesser commented Sep 12, 2018

Really thanks for your attention @jeffbarretocopam .

I verified and alter the connection of the JasperStudio do use same connector.

i dont understand as works the class.forName/classpath in jasperstarter and this has been killing me. Even pointing to the new connector, the old one is referenced.

To pattern, i have pointed out all the applications for use of connectorJ referenced in jasperstart, but get the same error.

dd($command);

jasperstarter --locale pt_BR process "C:\xampp\htdocs\application\public\reports\myreport.jrxml" -f pdf -t mysql -u root -p password -H 127.0.0.1 -n bd--db-port 3306 --db-driver com.mysql.cj.jdbc.Driver --db-url jdbc:mysql://localhost:3306/bd?useSSL=false&useTimezone=true&serverTimezone=UTC --jdbc-dir C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\mysql-connector-java-8.0.12

get

Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Wed Sep 12 17:39:41 BRT 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Unable to connect to database: The server time zone value 'Hora oficial do Brasil' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
'useTimezone' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
'serverTimezone' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.

The timezone error is caused by driver? Have any other ideia of the can cause this?
note:
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

Thanks again!

@jeffbarretocopam
Copy link
Contributor

Try
jasperstarter --locale pt_BR process "C:\xampp\htdocs\application\public\reports\myreport.jrxml" -f pdf -t mysql -u root -p password -H 127.0.0.1 -n bd--db-port 3306 --db-driver com.mysql.cj.jdbc.Driver --db-url "jdbc:mysql://localhost:3306/bd?useSSL=false&useTimezone=true&serverTimezone=UTC" --jdbc-dir C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\mysql-connector-java-8.0.12

case not work:

jasperstarter --locale pt_BR process "C:\xampp\htdocs\application\public\reports\myreport.jrxml" -f pdf -t mysql -u root -p password -H 127.0.0.1 -n bd--db-port 3306 --db-driver com.mysql.cj.jdbc.Driver --db-url jdbc:mysql://localhost:3306/bd?useSSL=false&useTimezone=true&serverTimezone=UTC --jdbc-dir C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\mysql-connector-java-8.0.12

Remember you need execute on ../yourproject/vendor/phpjasper/src/JasperStarter/bin/

@fabriciomesser
Copy link
Author

fabriciomesser commented Sep 14, 2018

Good morning!

I tryed to encapsule the command to isolate the special character &, but not work too.

Tryed open the cmd in administrator mode, but ...

Tomorrow i try again because my deadline is short. If i solve, i report the solution.

if you'll remember anything please report me.

Great weekend and thanks for help me. 👍

@atlet
Copy link

atlet commented Apr 4, 2019

@fabriciomesser Did you resolved this issue?

@atlet
Copy link

atlet commented Apr 4, 2019

Ok, I resolved this issue afrer putting in jdbc folder maria jdbc connector instead of mysql jdbc connector. Now it's working fine. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants