OctaviusDataSource

Implementation of the standard JDBC DataSource interface for the Octavius driver.

This class serves as a factory for obtaining connections to a PostgreSQL database. It encapsulates the configuration properties required to establish a connection, such as the server URL, credentials, and SSL settings.

Configuration properties can be set either via the url property or individually using the respective accessor properties. Every field of OctaviusProperties has an accessor here, so a pool that configures a DataSource through JavaBean setters - HikariCP's addDataSourceProperty, for one - can reach all of them; anything else goes through setProperty, including server startup parameters.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

The name this connection reports to the server, visible in pg_stat_activity. Unset, the driver's own name - Octavius Driver - is sent instead.

Link copied to clipboard

Seconds allowed for a cancel request, covering both its connect and its reads.

Link copied to clipboard

How hard to insist that authentication be bound to the TLS channel. Defaults to ChannelBinding.PREFER.

Link copied to clipboard
open override val connection: Connection
Link copied to clipboard

The name of the database to connect to.

Link copied to clipboard

Starting size, in bytes, of the per-connection parameter buffer.

Link copied to clipboard
open override var loginTimeout: Int
Link copied to clipboard

Whether a traced statement carries the values bound to it, rather than only how many there were. Off unless set, and effective only at trace.

Link copied to clipboard
open override var logWriter: PrintWriter?
Link copied to clipboard

Largest row, in bytes, kept in the reusable row buffer.

Link copied to clipboard

Cap for the per-connection parameter buffer; it shrinks back to initialParameterWriterCapacity after a query that exceeded it.

Link copied to clipboard

Fully-qualified class name of a NoticeHandler for server notices.

Link copied to clipboard

Capacity of the LISTEN/NOTIFY buffer.

Link copied to clipboard
open override val parentLogger: Logger
Link copied to clipboard

The password for authenticating with the database.

Link copied to clipboard

The port number on which the PostgreSQL server is listening. Defaults to 5432.

Link copied to clipboard

The hostname or IP address of the PostgreSQL server.

Link copied to clipboard

Seconds to wait on a socket read before failing. 0 waits forever.

Link copied to clipboard
var ssl: Boolean?

Shorthand raising the default SSL mode to REQUIRE. Ignored when sslmode is set explicitly.

Link copied to clipboard

The path to the client certificate file for SSL authentication. Takes effect only together with sslkey; with either missing, no client certificate is presented.

Link copied to clipboard

The path to the client private key file for SSL authentication. PKCS#8 in PEM form, encrypted or not - sslpassword opens an encrypted one - and RSA or EC alike, the algorithm being read off sslcert rather than assumed.

Link copied to clipboard

The SSL mode to use (e.g., disable, require, verify-ca, verify-full).

Link copied to clipboard

Decrypts sslkey where that key is encrypted - a PEM file opening on BEGIN ENCRYPTED PRIVATE KEY. An unencrypted key ignores it; an encrypted one without it is refused, naming this property.

Link copied to clipboard

The path to the root certificate file for verifying the server's certificate. Optional: left unset, verification under verify-ca and above uses the JVM's default trust store.

Link copied to clipboard
var url: String

The JDBC URL used to connect to the database. Setting this property will parse the URL and merge the properties.

Link copied to clipboard
var user: String?

The username for authenticating with the database.

Functions

Link copied to clipboard
Link copied to clipboard
open override fun getConnection(): Connection
open override fun getConnection(username: String?, pass: String?): Connection
Link copied to clipboard
open override fun getLoginTimeout(): Int
Link copied to clipboard
open override fun getLogWriter(): PrintWriter?
Link copied to clipboard

Retrieves a new OctaviusSession from this DataSource.

Retrieves a new OctaviusSession from this DataSource using the specified credentials.

Link copied to clipboard
open override fun getParentLogger(): Logger
Link copied to clipboard
open override fun isWrapperFor(iface: Class<*>): Boolean
Link copied to clipboard
open override fun setLoginTimeout(seconds: Int)
Link copied to clipboard
open override fun setLogWriter(out: PrintWriter?)
Link copied to clipboard
fun setProperty(name: String, value: String)

Sets any property this class does not expose directly, by the same name a JDBC URL would use. Anything the driver does not recognise is sent to the server as a startup parameter, which is what makes this the programmatic route to search_path, statement_timeout and friends - application_name has applicationName and needs no detour.

Link copied to clipboard
open override fun <T> unwrap(iface: Class<T>): T
Link copied to clipboard
inline fun <T> DataSource.unwrap(): T

Unwraps this DataSource to an instance of the specified type T.

Link copied to clipboard

Unwraps this DataSource to its underlying OctaviusDataSource instance.