MySQL JDBC Driver Time Zone Issue :: [SOLVED]

mysql jdbc driver time zone issue

Hey folks, when we try to create a java application with jdbc driver. most of time or likely first time we see an error that called JDBC Driver time zone issue. it looks something like this.

ERROR:

So how this error came up ,let me share the program that i wrote as a java application to query something with jdbc driver

File: Driver.java

the above program will generate that time zone error. in the line no 10 After your database name you have to add thisΒ  ?useTimezone=true&serverTimezone=UTCΒ .Β  After adding this code your code will look like this.

CORRECTION :

you amend this code into the above program and your program will be good to run. and you will get your desired output as i got. let me share the sample output i got.

SAMPLE OUTPUT:

 

23
Leave a Reply

avatar
14 Comment threads
9 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
14 Comment authors
KELVIN ASUaditnikkiMd Arifur Rahmaninico Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Bishop
Guest
Bishop

Thanks! Your info solved my problem. Cheers!

chux
Guest
chux

Thank you sir for this, but in my code I have mysqlx://localhost:3306/staffdb? user=chux&password=kingkong. So where do I add that line of code

Md Arifur Rahman
Admin

Okay chux, why don’t you try to put the code after your db name. if it dosen’t work then put after your parameter. But mostly we use it after dbname
Thanks for your comments

Daiga
Guest
Daiga

Thank you so much, this has been of great help.

Md Arifur Rahman
Admin

Hello Daiga, I am glad to hear this.

Md Arifur Rahman
Admin

Hello Daiga, I am glad to hear this. you are welcome

ryanb
Guest
ryanb

IT WORKS thank you so much, im struggling with default server zone time value in jdbc driver , and simply put UTC is works for me , thanks.

Allan Onyango
Guest
Allan Onyango

Thank you so much, dude

Bilal
Guest
Bilal

Thanks! it works for me, but with little change. it works for me by adding ?serverTimezone=UTC#

Md Arifur Rahman
Admin

Thank you so much Bilal,
Guys Please add this if my solution is not working for you.

Iniakpokeikiye Peter Thompson
Guest
Iniakpokeikiye Peter Thompson

Thanks a lot, it solved my problem

Claudio
Guest
Claudio

Thanks for share. It solved my problem.

Cheers.

Md Arifur Rahman
Admin

So glad to hear that buddy… Cheers

Lery
Guest
Lery

thank you very much! this helped clear my confusion πŸ˜€

Md Arifur Rahman
Admin

glad to hear that. you are welcome

inico
Guest
inico

As all other comments : thanks a lot !
This solved the issue I had.

Md Arifur Rahman
Admin

I am so glad that it helped you. cheers

nikki
Guest
nikki

saved my life! Being try to solve this with hours still didn’t find any helpful solution until I tried yours! Thx a lot!

Md Arifur Rahman
Admin

glad that it helped you.

adit
Guest
adit

thank you its working

KELVIN ASU
Guest
KELVIN ASU

THANK U SO MUCH FOR THIS WONDERFUL ARTICLE. IT REALLY HELPED ME

KELVIN ASU
Guest
KELVIN ASU

CAN YOU WRITE AN ARTICLE HOW TO PACKAGE A JDBC APPLICATION AND INSTALL IT ON THE COMPUTER OF THE CLIENT?. I WILL BE SO GRATEFUL

Md Arifur Rahman
Admin

Hi Kelvin, Thank you so much for this lovely request. Can you please be a little bit specific about your requirements. I would love to create the application. Okay, you can write me up or either I am going to write in this way that a java application that will use JDBC to do the CRUD option and by maven we will generate the war file and we will deploy to any java supported server. that sounds a lot of great stuff .. I am excited. See you there.