0
votes

I'm trying to connect a springboot project to a CLOUD SQL db and i go the error :

com.mysql.cj.exceptions.CJException: Access denied for user 'user'@'IP' (using password: YES).

and

SQL State : 08001 Error Code : 0 Message : Could not create connection to database server. Attempted reconnect 3 times. Giving up.

I tried to connect to this CloudSQL instance using the mysql-client with the same user ans passsword and it works perfectly.

Here is the springboot conf i'm using:

spring:
  datasource:
    url: jdbc:mysql://INSTANCE_IP/DB_NAME?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&autoReconnect=true&useSSL=false
    username: USERNAME
    password: PASSWORD

Has anyone an idea of what i am doing wrong ?

1

1 Answers

0
votes

This is a MySQL exception that occurs when you have the wrong username or password. There is a detailed explanation here.

I would also suggest checking out the Cloud SQL JDBC Socket Factory, which can help Java users connect to Cloud SQL.