Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost:5432/mydb"; String user = "postgres"; String password = "password";
: It is a genuine JDBC-compliant driver registered against the DriverManager upon class loading. Implementation and Setup postgresql jdbc driver
| Fetch size | Behavior | |------------|----------| | 0 (default) | Materialize entire ResultSet in memory. | | >0 | Stream rows; each next() fetches one row (minimal memory). | | Integer.MIN_VALUE | Force single-row fetch (for very large results). |
| Feature | Method/Class | Use Case | |---------|-------------|----------| | COPY support | PgConnection.getCopyAPI() | High-speed bulk import/export. | | LISTEN/NOTIFY | PGNotification , getNotifications() | Real-time eventing. | | Large Objects | LargeObject , LargeObjectManager | Binary data >1GB. | | Array types | java.sql.Array | PostgreSQL array ↔ Java array. | | JSON/JSONB | PGobject with type "json" | Native JSON handling. | | Composite types | PGobject | User-defined types. | | Logical replication | PgReplicationConnection | CDC (Change Data Capture). | | | Integer
PGJDBC-2024-01 Date: October 26, 2023 (Updated for modern versions) Subject: Evaluation of architecture, features, performance, and security of the official PostgreSQL JDBC driver.
The standard way to connect is via the DriverManager using a connection URL. | | Large Objects | LargeObject , LargeObjectManager
| Parameter | Default | Description | |-----------|---------|-------------| | ssl | false | Enable SSL/TLS. | | sslmode | prefer | disable , allow , prefer , require , verify-ca , verify-full . | | currentSchema | public | Set default schema search path. | | prepareThreshold | 5 | Number of executions before using server-prepared statements. | | preparedStatementCacheQueries | 256 | Cache size for prepared statements. | | tcpKeepAlive | false | Enable TCP keepalive. | | connectTimeout | 10 (sec) | Socket connection timeout. | | socketTimeout | 0 (infinite) | Socket read timeout. | | ApplicationName | (empty) | Identifies the application in pg_stat_activity . | | reWriteBatchedInserts | false | Rewrite batched INSERTs for performance. |