Cloud SQL MySQL Socket Factory (for Connector/J 6.x)

Socket factory for the MySQL JDBC driver (version 6.x) that allows a user with the appropriate permissions to connect to a Cloud SQL database without having to deal with IP whitelisting or SSL certificates manually.

License

License

Categories

Categories

MySQL Data Databases
GroupId

GroupId

com.google.cloud.sql
ArtifactId

ArtifactId

mysql-socket-factory-connector-j-6
Last Version

Last Version

1.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

Cloud SQL MySQL Socket Factory (for Connector/J 6.x)
Socket factory for the MySQL JDBC driver (version 6.x) that allows a user with the appropriate permissions to connect to a Cloud SQL database without having to deal with IP whitelisting or SSL certificates manually.

Download mysql-socket-factory-connector-j-6

How to add to project

<!-- https://jarcasting.com/artifacts/com.google.cloud.sql/mysql-socket-factory-connector-j-6/ -->
<dependency>
    <groupId>com.google.cloud.sql</groupId>
    <artifactId>mysql-socket-factory-connector-j-6</artifactId>
    <version>1.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.google.cloud.sql/mysql-socket-factory-connector-j-6/
implementation 'com.google.cloud.sql:mysql-socket-factory-connector-j-6:1.2.1'
// https://jarcasting.com/artifacts/com.google.cloud.sql/mysql-socket-factory-connector-j-6/
implementation ("com.google.cloud.sql:mysql-socket-factory-connector-j-6:1.2.1")
'com.google.cloud.sql:mysql-socket-factory-connector-j-6:jar:1.2.1'
<dependency org="com.google.cloud.sql" name="mysql-socket-factory-connector-j-6" rev="1.2.1">
  <artifact name="mysql-socket-factory-connector-j-6" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.google.cloud.sql', module='mysql-socket-factory-connector-j-6', version='1.2.1')
)
libraryDependencies += "com.google.cloud.sql" % "mysql-socket-factory-connector-j-6" % "1.2.1"
[com.google.cloud.sql/mysql-socket-factory-connector-j-6 "1.2.1"]

Dependencies

compile (3)

Group / Artifact Type Version
com.google.cloud.sql : jdbc-socket-factory-core jar 1.2.1
com.github.jnr : jnr-unixsocket jar 0.38.5
org.ow2.asm : asm-util jar 9.1

provided (1)

Group / Artifact Type Version
mysql : mysql-connector-java jar 6.0.6

test (3)

Group / Artifact Type Version
junit : junit jar 4.13.2
com.google.truth : truth jar 1.1.2
com.zaxxer : HikariCP jar 4.0.2

Project Modules

There are no modules declared in this project.

Cloud SQL Connector for Java

CI Java 8 CI Java 11

The Cloud SQL Connector for Java is a library that provides IAM-based authorization and encryption when connecting to a Cloud SQL instance. It can not provide a network path to a Cloud SQL instance if one is not already present. See the Connecting Overview page for more information on connecting to a Cloud SQL instance.

Usage

For usage information specific to your database engine and driver, see the pages below:

JDBC:

R2DBC:

For examples of this library being used in the context of an application, check out the sample applications located here.

Authentication

This library uses Application Default Credentials to authenticate the connection to the Cloud SQL server. For more details, see the previously mentioned link.

To activate credentials locally, use the following gcloud command:

gcloud auth application-default login

Building the Drivers

To build a fat JAR containing the JDBC driver with the bundles Socket Factory dependencies you can issue the following Maven command from the location containing the project pom.xml:

mvn -P jar-with-dependencies clean package -DskipTests

This will create a target sub-folder within each of the module directories. Within these target directories you'll find the JDBC driver files.

Example:

mysql-socket-factory-connector-j-8–1.2.1-jar-with-dependencies.jar
postgres-socket-factory-1.2.1-jar-with-dependencies.jar

Firewall configuration

The Cloud SQL proxy establishes connections to Cloud SQL instances using port 3307. Applications that are protected by a firewall may need to be configured to allow outgoing connections on TCP port 3307. A connection blocked by a firewall typically results in an error stating connection failure (e.g. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure).

Connect with IntelliJ

In order to connect IntelliJ to your Cloud SQL instance, you will need to add this library as a jar with dependencies in "Additional Files" section on the driver settings page. Prebuilt fat jars can be found on the Releases page for this purpose.

Troubleshooting

Here are some troubleshooting tips to resolve common issues that come up when using the Java Connector:

  1. Make sure you are using the latest version of the Cloud SQL Connector and your database driver to avoid incompatibilities. Some older versions of drivers are not supported
  2. The Java connector provides authorization for connections, but it does not provide new paths to connectivity. For example, in order to connect to a Cloud SQL instance using a Private IP address, your application must already have VPC access.
com.google.cloud.sql

Google Cloud Platform

Versions

Version
1.2.1
1.2.0
1.1.0
1.0.16
1.0.15
1.0.14
1.0.13
1.0.12
1.0.11
1.0.10
1.0.9
1.0.8
1.0.7
1.0.5
1.0.4
1.0.3
1.0.2