Connect to MySQL 8 with Java

Introduction

In the work I'm currently involved in, I decided to change from Java7 to Java11 and MySQL5.5 to MySQL8.0, so this is a memo for that.

Get the driver

Select the 8.x one from the Maven repository and get it.

https://mvnrepository.com/artifact/mysql/mysql-connector-java

I'm Gradle, so I rewrote it as follows.

    implementation  "mysql:mysql-connector-java:8.0.17"

Driver name change

Before change: com.mysql.jdbc.Driver After change: com.mysql.cj.jdbc.Driver

URL

Before change: jdbc: mysql: // localhost: 3306 / test After change: jdbc: mysql: // localhost: 3306 / test? characterEncoding = utf8 & useSSL = false & serverTimezone = GMT% 2B9 & rewriteBatchedStatements = true

I don't understand it yet, but it seems that I need to add various things to the back. serverTimezone = GMT% 2B9 seems to specify the Japanese time zone "GMT + 9".

Finally

There are too many changes and it's hard ...

Recommended Posts

Connect to MySQL 8 with Java
[Java] Connect to MySQL
Connect to DB with Java
Connect from Java to MySQL using Eclipse
Connect to Aurora (MySQL) from a Java application
[Template] MySQL connection with Java
Java to play with Function
Connect from Java to PostgreSQL
Connect to oracle with eclipse!
[Android] Connect to MySQL (unfinished)
How to connect MySQL / MariaDB + HikariCP with Liferay 7 / DXP
I started MySQL 5.7 with docker-compose and tried to connect
[Java] I tried to connect using a connection pool with Servlet (tomcat) & MySQL & Java
Operation to connect multiple Streams @Java
Java to learn with ramen [Part 1]
[Java] Points to note with Arrays.asList ()
Dare to challenge Kaggle with Java (1)
mysql2 fails to install with bundle install
I tried to interact with Java
Connect to Rails server with iPhone
Java, arrays to start with beginners
Update MySQL from 5.7 to 8.0 with Docker
Connect to multiple MySQL instances with SSL enabled in JDBC
Connect to Amazon EC2 with SSH (Ubuntu)
How to compile Java with VsCode & Ant
[Java] How to compare with equals method
Introduction to algorithms with java --Search (depth-first search)
[Java] Introduction to Java
Introduction to java
Easy to trip with Java regular expressions
Introduction to algorithms with java --Search (breadth-first search)
Challenge to deal with garbled characters with Java AudioSystem.getMixerInfo ()
[Java] How to test for null with JUnit
I tried to make Basic authentication with Java
Create a simple bulletin board with Java + MySQL
Deploy Java web app to Azure with maven
Try to link Ruby and Java with Dapr
How to use Java framework with AWS Lambda! ??
I want to use java8 forEach with index
How to use Java API with lambda expression
Getting started with Kotlin to send to Java developers
Try to implement TCP / IP + NIO with JAVA
[Java / PostgreSQL] Connect the WEB application to the database
[Java] Article to add validation with Spring Boot 2.3.1.
Error deploying rails5 + Mysql to heroku with Docker-compose
Easy to make LINE BOT with Java Servlet
I tried to break a block with java (1)
Connect nestjs project created by Nx with mysql
Install java with Homebrew
Changes from Java 8 to Java 11
Sum from Java_1 to 100
Change seats with java
Solution that gives an error when trying to connect to DB (MySQL) in Java
Install Java with Ansible
Comfortable download with JAVA
Switch java with direnv
Kotlin's improvements to Java
From Java to Ruby !!
Download Java with Ansible
[Docker] Connection with MySQL
[Rails] Development with MySQL