Registry / database / postgres-socket-factory

postgres-socket-factory

JSON →
library1.28.2javamavenunverified

Socket factory for the Postgres JDBC driver that allows a user with the appropriate permissions to connect to a Cloud SQL database without having to deal with IP allowlisting or SSL certificates manually.

<dependency> <groupId>com.google.cloud.sql</groupId> <artifactId>postgres-socket-factory</artifactId> <version>1.28.2</version> </dependency>
INSTALL
IMPORT
SIG · POSTGRES-SOCKET-FA
P
postgres-socket-factory
databasejavav1.28.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SocketFactory
com.google.cloud.sql.postgres.SocketFactory

Connects to a Cloud SQL Postgres database using the socket factory.

import com.google.cloud.sql.postgres.SocketFactory; import java.sql.Connection; import java.sql.DriverManager; import java.util.Properties; public class Example { public static void main(String[] args) throws Exception { String url = "jdbc:postgresql:///<DATABASE_NAME>"; Properties props = new Properties(); props.setProperty("user", "<USER>"); props.setProperty("password", "<PASSWORD>"); props.setProperty("cloudSqlInstance", "<INSTANCE_CONNECTION_NAME>"); props.setProperty("socketFactory", "com.google.cloud.sql.postgres.SocketFactory"); Connection conn = DriverManager.getConnection(url, props); System.out.println("Connected: " + conn); } }
Debug
Known issues
gotchaRequires the Cloud SQL Admin API to be enabled and appropriate IAM permissions.
fix
Enable the API and grant the Cloud SQL Client role to the service account.
affects: *
Upgrade
Version history
1.28.2latest on Maven
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
18
Amazon
1
Resources
postgres-socket-factory — mvn dependency:get postgres-socket-factory · libregistry