Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3751330
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:03:33+00:00 2026-05-19T09:03:33+00:00

I have a MySQL Server set to UTC (@@global.time_zone = ‘+00:00’) and a table

  • 0

I have a MySQL Server set to UTC (@@global.time_zone = ‘+00:00’) and a table with a DATETIME column in which I store dates in UTC. I’m having problems getting UTC dates to come through when I call a stored procedure via JDBC. Example:

java.util.Date now = new java.util.Date();
sproc = conn.prepareCall("{call TzTestInsert(?)}");
sproc.setTimestamp(1, new java.sql.Timestamp(now.getTime()), Calendar.getInstance(TimeZone.getTimeZone("GMT+00:00")));
sproc.execute();

The TzTestInsert sproc simply takes a DATETIME and inserts it into the table.

I’d expect the database to now hold my current time in UTC, but in fact it holds the current time for my timezone.

If I change the sproc to take a string it works…

DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
...
sproc.setString(1, dateFormat.format(now));

but I’d rather use the correct type in the sproc.

Also works if I bypass the sproc, but again not my preferred solution…

String sql = "INSERT INTO TzTest VALUES('" + dateFormat.format(now) + "') ;

With the original sproc I have the same issue if I use a TIMESTAMP datatype in the sproc and table, which isn’t surprising with the server in UTC since any timezone conversions specific to MySQL TIMESTAMP should be noops.

Calling the sproc from a MySQL Workbench connection works fine, e.g.

CALL TzTestInsert(UTC_TIMESTAMP());

Seems like the problem is in JDBC. I’ve looked at the various timezone connection parameters and haven’t found any that make a difference.

I must be missing something basic – lots of people do this, right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:03:34+00:00Added an answer on May 19, 2026 at 9:03 am

    Solution was to pass the JDBC driver “useLegacyDatetimeCode=false”. See mysql bug http://bugs.mysql.com/bug.php?id=15604

    Looks like they left the old code in the driver for backwards compatibility.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have config.time_zone in environment.rb set to UTC, and my mySQL server returns the
I have a nullable DateTime column in my SQL Server 2005 table called DateTimeDeleted.
I have to migrate a table from MSSQL Server to MySql. The problem is
(Note: This is for MySQL's SQL, not SQL Server.) I have a database column
I have a mysql server which is occasionly returns the 'too many connections' error.
I have my MySQL server running with 4 databases and innodb_data_file_path set to the
I have an SSIS package that connects to a mysql server and attempts to
I have a web site using apache httpd as the server and mysql as
Does Microsoft Access have Full Text Search? I know that MySQL and SQL Server
I have a fairly small MySQL database (a Textpattern install) on a server that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.