Driver Jdbc Postgresql [verified] May 2026
org.postgresql.Driver Maven Central coordinates: org.postgresql:postgresql 2. Adding the Driver to Your Project Maven <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.7.1</version> <!-- Check for latest --> </dependency> Gradle implementation 'org.postgresql:postgresql:42.7.1' Manual (JAR download) Download from jdbc.postgresql.org 3. Basic Connection Example import java.sql.*; public class PostgresExample public static void main(String[] args) String url = "jdbc:postgresql://localhost:5432/mydb"; String user = "postgres"; String password = "secret";
// READ try (PreparedStatement ps = conn.prepareStatement( "SELECT * FROM users WHERE id = ?")) ps.setInt(1, 1); ResultSet rs = ps.executeQuery(); if (rs.next()) String name = rs.getString("name"); driver jdbc postgresql
| Format | Example | |--------|---------| | Basic | jdbc:postgresql://host:port/database | | With parameters | jdbc:postgresql://localhost:5432/mydb?ssl=true&sslmode=require | | Hostless (local socket) | jdbc:postgresql:///mydb | Common connection parameters | Parameter | Description | Default | |-----------|-------------|---------| | ssl | Enable SSL | false | | sslmode | disable , require , verify-ca , verify-full | prefer | | currentSchema | Default schema | public | | connectTimeout | Connection timeout (seconds) | 10 | | socketTimeout | Socket read timeout (seconds) | 0 (infinite) | | ApplicationName | Identifies app in pg_stat_activity | PostgreSQL JDBC Driver | 5. Using Connection Pools (Recommended for Production) import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; HikariConfig config = new HikariConfig(); config.setJdbcUrl("jdbc:postgresql://localhost:5432/mydb"); config.setUsername("postgres"); config.setPassword("secret"); config.setMaximumPoolSize(10); HikariConfig config = new HikariConfig()