Skip to content

Commit

Permalink
docs: add R2DBC connector info to README (#302)
Browse files Browse the repository at this point in the history
* chore: add R2DBC connector info to README

* Separate JDBC and R2DBC Sections

* Update README.md

* Update README.md
  • Loading branch information
shubha-rajan authored Sep 25, 2020
1 parent 3716d6d commit d20e54d
Showing 1 changed file with 88 additions and 7 deletions.
95 changes: 88 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
## Cloud SQL Socket Factory for JDBC drivers
## Cloud SQL Connector for Java
[![Build
Status](https://travis-ci.org/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory)

The Cloud SQL Socket Factory is a library for the MySQL/Postgres JDBC drivers that allows a user
The Cloud SQL Connector for Java is a library for the MySQL/Postgres JDBC and R2DBC drivers 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.

## Instructions

### Examples

## Examples

For examples of this library being used in the context of an application, check out the sample
applications located
[here](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/cloud-sql).

### Authentication
## Authentication

This library uses the [Application Default Credentials](
https://developers.google.com/identity/protocols/application-default-credentials) to authenticate
Expand All @@ -25,6 +25,9 @@ command:
```bash
gcloud auth application-default login
```
---

## Instructions for JDBC

### Add library as a dependency

Expand All @@ -39,10 +42,10 @@ are unsure, it is recommended to use the latest version of `mysql-connector-java
| mysql-connector-java:6.x | mysql-socket-factory-connector-j-6:1.0.16 |
| mysql-connector-java:5.1.x | mysql-socket-factory:1.0.16 |

[//]: # ({x-version-update-start:cloud-sql-java-connector:released})

##### Maven
Include the following in the project's `pom.xml`:
[//]: # ({x-version-update-start:cloud-sql-java-connector:released})
Include the following in the project's `pom.xml`:
```maven-pom
<dependency>
    <groupId>com.google.cloud.sql</groupId>
Expand Down Expand Up @@ -74,8 +77,11 @@ Include the following the project's `gradle.build`
```gradle
compile 'com.google.cloud.sql:postgres-socket-factory:1.1.0'
```
*Note: Also include the JDBC Driver for MySQL, `org.postgresql:postgresql:<LATEST-VERSION>`

[//]: # ({x-version-update-end})


#### Creating the JDBC URL

##### MySQL
Expand Down Expand Up @@ -120,6 +126,81 @@ Note: The host portion of the JDBC URL is currently unused, and has no effect on

---

## Instructions for R2DBC

### Add library as a dependency

[//]: # ({x-version-update-start:cloud-sql-java-connector:released})

#### MySQL

##### Maven
Include the following in the project's `pom.xml`:
```maven-pom
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>cloud-sql-connector-r2dbc-mysql</artifactId>
<version>1.1.0</version>
</dependency>
```

##### Gradle
Include the following the project's `build.gradle`
```gradle
compile 'com.google.cloud.sql:cloud-sql-connector-r2dbc-mysql:1.1.0'
```

*Note: Also include the R2DBC Driver for MySQL, `dev.miku:r2dbc-mysql:<LATEST-VERSION>`

#### PostgreSQL

##### Maven
Include the following in the project's `pom.xml`:
```maven-pom
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>cloud-sql-connector-r2dbc-postgres</artifactId>
<version>1.1.0</version>
</dependency>
```
##### Gradle
Include the following the project's `build.gradle`
```gradle
compile 'com.google.cloud.sql:cloud-sql-connector-r2dbc-postgres:1.1.0'
```
*Note: Also include the R2DBC Driver for Postgres, `io.r2dbc:r2dbc-postgresql:<LATEST-VERSION>`

[//]: # ({x-version-update-end})

#### Creating the R2DBC URL

##### MySQL
R2DBC URL template: `r2dbc:gcp:mysql//<DB_USER>:<DB_PASS>@<CLOUD_SQL_CONNECTION_NAME>/<DATABASE_NAME>`

Add the following parameters:

| Property | Value |
| ---------------- | ------------- |
| DATABASE_NAME | The name of the database to connect to |
| CLOUD_SQL_CONNECTION_NAME | The instance connection name (found on the instance details page) |
| DB_USER | MySQL username |
| DB_PASS | MySQL user's password |


##### Postgres
R2DBC URL template: `r2dbc:gcp:postgres//<DB_USER>:<DB_PASS>@<CLOUD_SQL_CONNECTION_NAME>/<DATABASE_NAME>`

Add the following parameters:

| Property | Value |
| ---------------- | ------------- |
| DATABASE_NAME | The name of the database to connect to |
| CLOUD_SQL_CONNECTION_NAME | The instance connection name (found on the instance details page) |
| DB_USER | Postgres username |
| DB_PASS | Postgres user's password |

---

## 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:

Expand Down

0 comments on commit d20e54d

Please sign in to comment.