All Projects → pgjdbc → Pgjdbc

pgjdbc / Pgjdbc

Licence: bsd-2-clause
Postgresql JDBC Driver

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Pgjdbc

Jooq
jOOQ is the best way to write SQL in Java
Stars: ✭ 4,695 (+407.57%)
Mutual labels:  jdbc, postgresql
Scala Db Codegen
Scala code/boilerplate generator from a db schema
Stars: ✭ 49 (-94.7%)
Mutual labels:  jdbc, postgresql
Pgjdbc Ng
A new JDBC driver for PostgreSQL aimed at supporting the advanced features of JDBC and Postgres
Stars: ✭ 500 (-45.95%)
Mutual labels:  jdbc, postgresql
Scalikejdbc
A tidy SQL-based DB access library for Scala developers. This library naturally wraps JDBC APIs and provides you easy-to-use APIs.
Stars: ✭ 1,139 (+23.14%)
Mutual labels:  jdbc, postgresql
Hibernate Springboot
Collection of best practices for Java persistence performance in Spring Boot applications
Stars: ✭ 589 (-36.32%)
Mutual labels:  jdbc, postgresql
Pg acoustid
PostgreSQL extension for working with AcoustID fingerprints
Stars: ✭ 6 (-99.35%)
Mutual labels:  postgresql
Es Cqrs Shopping Cart
A resilient and scalable shopping cart system designed using Event Sourcing (ES) and Command Query Responsibility Segregation (CQRS)
Stars: ✭ 19 (-97.95%)
Mutual labels:  postgresql
Diesel
A safe, extensible ORM and Query Builder for Rust
Stars: ✭ 7,702 (+732.65%)
Mutual labels:  postgresql
Sqltabs
Rich SQL client for Postgresql, MySQL, MS SQL, Amazon Redshift, Google Firebase (Firestore)
Stars: ✭ 809 (-12.54%)
Mutual labels:  postgresql
Experdb Db2pg
eXperDB-DB2PG is a data migration solution that transfers data extracted from various DBMSs to eXperDB or PostgreSQL. Currently, Oracle and Oracle Spatial, MySQL, SQL Server(MS-SQL) and Sybase data can be transferred.
Stars: ✭ 24 (-97.41%)
Mutual labels:  postgresql
Fastapi Realworld Example App
Backend logic implementation for https://github.com/gothinkster/realworld with awesome FastAPI
Stars: ✭ 911 (-1.51%)
Mutual labels:  postgresql
Serverless Aws Lambda Node Postgres
Serverless AWS Lambda with Node.js,Postgres Rest API with Sequelize.
Stars: ✭ 18 (-98.05%)
Mutual labels:  postgresql
Efcore.pg
Entity Framework Core provider for PostgreSQL
Stars: ✭ 838 (-9.41%)
Mutual labels:  postgresql
Pgx
Build Postgres Extensions with Rust!
Stars: ✭ 903 (-2.38%)
Mutual labels:  postgresql
Supabase
The open source Firebase alternative. Follow to stay updated about our public Beta.
Stars: ✭ 25,142 (+2618.05%)
Mutual labels:  postgresql
Myjdbc Rainbow
jpa--轻量级orm模式对象与数据库映射api
Stars: ✭ 23 (-97.51%)
Mutual labels:  jdbc
Docker Postgis
Docker image for PostGIS
Stars: ✭ 821 (-11.24%)
Mutual labels:  postgresql
Auto App
Crie um aplicativo com todas as tabelas de um dos seus bancos sem uma linha de código.
Stars: ✭ 18 (-98.05%)
Mutual labels:  postgresql
Docker Postgres
A docker container running PostgreSQL
Stars: ✭ 22 (-97.62%)
Mutual labels:  postgresql
Great Big Example Application
A full-stack example app built with JHipster, Spring Boot, Kotlin, Angular 4, ngrx, and Webpack
Stars: ✭ 899 (-2.81%)
Mutual labels:  postgresql
Slonik Duke

PostgreSQL JDBC Driver

PostgreSQL JDBC Driver (PgJDBC for short) allows Java programs to connect to a PostgreSQL database using standard, database independent Java code. Is an open source JDBC driver written in Pure Java (Type 4), and communicates in the PostgreSQL native network protocol.

Status

Build status Build Status codecov.io Maven Central Javadocs License Join the chat at https://gitter.im/pgjdbc/pgjdbc

Supported PostgreSQL and Java versions

The current version of the driver should be compatible with PostgreSQL 8.4 and higher using the version 3.0 of the protocol and Java 8 (JDBC 4.2) or above. Unless you have unusual requirements (running old applications or JVMs), this is the driver you should be using.

PgJDBC regression tests are run against all PostgreSQL versions since 8.4, including "build PostgreSQL from git master" version. There are other derived forks of PostgreSQL but have not been certified to run with PgJDBC. If you find a bug or regression on supported versions, please fill an Issue.

Get the Driver

Most people do not need to compile PgJDBC. You can download the precompiled driver (jar) from the PostgreSQL JDBC site or using your chosen dependency management tool:

Maven Central

You can search on The Central Repository with GroupId and ArtifactId Maven Search for:

Java 8

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.2.16</version>
</dependency>

Development snapshots

Snapshot builds (builds from master branch) are also deployed to Maven Central, so you can test current development version (test some bugfix) using:

<dependency>
  <groupId>org.postgresql</groupId>
  <artifactId>postgresql</artifactId>
  <version>42.3.0-SNAPSHOT</version> <!-- Java 8 -->
</dependency>

There are also available (snapshot) binary RPMs in Fedora's Copr repository.


Documentation

For more information you can read the PgJDBC driver documentation or for general JDBC documentation please refer to The Java™ Tutorials.

Driver and DataSource class

Implements Class
java.sql.Driver org.postgresql.Driver
javax.sql.DataSource org.postgresql.ds.PGSimpleDataSource
javax.sql.ConnectionPoolDataSource org.postgresql.ds.PGConnectionPoolDataSource
javax.sql.XADataSource org.postgresql.xa.PGXADataSource

Building the Connection URL

The driver recognises JDBC URLs of the form:

jdbc:postgresql:database
jdbc:postgresql:
jdbc:postgresql://host/database
jdbc:postgresql://host/
jdbc:postgresql://host:port/database
jdbc:postgresql://host:port/

The general format for a JDBC URL for connecting to a PostgreSQL server is as follows, with items in square brackets ([ ]) being optional:

jdbc:postgresql:[//host[:port]/][database][?property1=value1[&property2=value2]...]

where:

  • jdbc:postgresql: (Required) is known as the sub-protocol and is constant.
  • host (Optional) is the server address to connect. This could be a DNS or IP address, or it could be localhost or 127.0.0.1 for the local computer. To specify an IPv6 address your must enclose the host parameter with square brackets (jdbc:postgresql://[::1]:5740/accounting). Defaults to localhost.
  • port (Optional) is the port number listening on the host. Defaults to 5432.
  • database (Optional) is the database name. Defaults to the same name as the user name used in the connection.
  • propertyX (Optional) is one or more option connection properties. For more information see Connection properties.

Connection Properties

In addition to the standard connection parameters the driver supports a number of additional properties which can be used to specify additional driver behaviour specific to PostgreSQL™. These properties may be specified in either the connection URL or an additional Properties object parameter to DriverManager.getConnection.

Property Type Default Description
user String null The database user on whose behalf the connection is being made.
password String null The database user's password.
options String null Specify 'options' connection initialization parameter.
ssl Boolean false Control use of SSL (true value causes SSL to be required)
sslfactory String null Provide a SSLSocketFactory class when using SSL.
sslfactoryarg (deprecated) String null Argument forwarded to constructor of SSLSocketFactory class.
sslmode String prefer Controls the preference for opening using an SSL encrypted connection.
sslcert String null The location of the client's SSL certificate
sslkey String null The location of the client's PKCS#8 SSL key
sslrootcert String null The location of the root certificate for authenticating the server.
sslhostnameverifier String null The name of a class (for use in Class.forName(String)) that implements javax.net.ssl.HostnameVerifier and can verify the server hostname.
sslpasswordcallback String null The name of a class (for use in Class.forName(String)) that implements javax.security.auth.callback.CallbackHandler and can handle PasswordCallback for the ssl password.
sslpassword String null The password for the client's ssl key (ignored if sslpasswordcallback is set)
sendBufferSize Integer -1 Socket write buffer size
receiveBufferSize Integer -1 Socket read buffer size
loggerLevel String null Logger level of the driver using java.util.logging. Allowed values: OFF, DEBUG or TRACE.
loggerFile String null File name output of the Logger, if set, the Logger will use a FileHandler to write to a specified file. If the parameter is not set or the file can't be created the ConsoleHandler will be used instead.
allowEncodingChanges Boolean false Allow for changes in client_encoding
logUnclosedConnections Boolean false When connections that are not explicitly closed are garbage collected, log the stacktrace from the opening of the connection to trace the leak source
binaryTransferEnable String "" Comma separated list of types to enable binary transfer. Either OID numbers or names
binaryTransferDisable String "" Comma separated list of types to disable binary transfer. Either OID numbers or names. Overrides values in the driver default set and values set with binaryTransferEnable.
prepareThreshold Integer 5 Statement prepare threshold. A value of -1 stands for forceBinary
preparedStatementCacheQueries Integer 256 Specifies the maximum number of entries in per-connection cache of prepared statements. A value of 0 disables the cache.
preparedStatementCacheSizeMiB Integer 5 Specifies the maximum size (in megabytes) of a per-connection prepared statement cache. A value of 0 disables the cache.
defaultRowFetchSize Integer 0 Positive number of rows that should be fetched from the database when more rows are needed for ResultSet by each fetch iteration
loginTimeout Integer 0 Specify how long to wait for establishment of a database connection.
connectTimeout Integer 10 The timeout value used for socket connect operations.
socketTimeout Integer 0 The timeout value used for socket read operations.
tcpKeepAlive Boolean false Enable or disable TCP keep-alive.
ApplicationName String null The application name (require server version >= 9.0)
readOnly Boolean true Puts this connection in read-only mode
disableColumnSanitiser Boolean false Enable optimization that disables column name sanitiser
assumeMinServerVersion String null Assume the server is at least that version
currentSchema String null Specify the schema (or several schema separated by commas) to be set in the search-path
targetServerType String any Specifies what kind of server to connect, possible values: any, master, slave (deprecated), secondary, preferSlave (deprecated), preferSecondary
hostRecheckSeconds Integer 10 Specifies period (seconds) after which the host status is checked again in case it has changed
loadBalanceHosts Boolean false If disabled hosts are connected in the given order. If enabled hosts are chosen randomly from the set of suitable candidates
socketFactory String null Specify a socket factory for socket creation
socketFactoryArg (deprecated) String null Argument forwarded to constructor of SocketFactory class.
autosave String never Specifies what the driver should do if a query fails, possible values: always, never, conservative
cleanupSavepoints Boolean false In Autosave mode the driver sets a SAVEPOINT for every query. It is possible to exhaust the server shared buffers. Setting this to true will release each SAVEPOINT at the cost of an additional round trip.
preferQueryMode String extended Specifies which mode is used to execute queries to database, possible values: extended, extendedForPrepared, extendedCacheEverything, simple
reWriteBatchedInserts Boolean false Enable optimization to rewrite and collapse compatible INSERT statements that are batched.
escapeSyntaxCallMode String select Specifies how JDBC escape call syntax is transformed into underlying SQL (CALL/SELECT), for invoking procedures or functions (requires server version >= 11), possible values: select, callIfNoReturn, call
maxResultBuffer String null Specifies size of result buffer in bytes, which can't be exceeded during reading result set. Can be specified as particular size (i.e. "100", "200M" "2G") or as percent of max heap memory (i.e. "10p", "20pct", "50percent")
gssEncMode String allow Controls the preference for using GSSAPI encryption for the connection, values are disable, allow, prefer, and require
adaptiveFetch Boolean false Specifies if number of rows fetched in ResultSet by each fetch iteration should be dynamic. Number of rows will be calculated by dividing maxResultBuffer size into max row size observed so far. Requires declaring maxResultBuffer and defaultRowFetchSize for first iteration.
adaptiveFetchMinimum Integer 0 Specifies minimum number of rows, which can be calculated by adaptiveFetch. Number of rows used by adaptiveFetch cannot go below this value.
adaptiveFetchMaximum Integer -1 Specifies maximum number of rows, which can be calculated by adaptiveFetch. Number of rows used by adaptiveFetch cannot go above this value. Any negative number set as adaptiveFetchMaximum is used by adaptiveFetch as infinity number of rows.
localSocketAddress String null Hostname or IP address given to explicitly configure the interface that the driver will bind the client side of the TCP/IP connection to when connecting.

Contributing

For information on how to contribute to the project see the Contributing Guidelines


Sponsors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].