Class PgConnection

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int defaultFetchSize
      Default fetch size for statement.
      protected boolean forcebinary  
      protected java.sql.DatabaseMetaData metadata  
      protected int prepareThreshold  
      protected java.util.Map<java.lang.String,​java.lang.Class<?>> typemap
      The current type mappings.
      • Fields inherited from interface java.sql.Connection

        TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
    • Constructor Summary

      Constructors 
      Constructor Description
      PgConnection​(HostSpec[] hostSpecs, java.lang.String user, java.lang.String database, java.util.Properties info, java.lang.String url)  
    • Field Detail

      • prepareThreshold

        protected int prepareThreshold
      • forcebinary

        protected boolean forcebinary
      • typemap

        protected java.util.Map<java.lang.String,​java.lang.Class<?>> typemap
        The current type mappings.
      • metadata

        protected java.sql.DatabaseMetaData metadata
    • Constructor Detail

      • PgConnection

        public PgConnection​(HostSpec[] hostSpecs,
                            java.lang.String user,
                            java.lang.String database,
                            java.util.Properties info,
                            java.lang.String url)
                     throws java.sql.SQLException
        Throws:
        java.sql.SQLException
    • Method Detail

      • createQuery

        public CachedQuery createQuery​(java.lang.String sql,
                                       boolean escapeProcessing,
                                       boolean isParameterized,
                                       java.lang.String... columnNames)
                                throws java.sql.SQLException
        Specified by:
        createQuery in interface BaseConnection
        Throws:
        java.sql.SQLException
      • setFlushCacheOnDeallocate

        public void setFlushCacheOnDeallocate​(boolean flushCacheOnDeallocate)
        Description copied from interface: BaseConnection
        By default, the connection resets statement cache in case deallocate all/discard all message is observed. This API allows to disable that feature for testing purposes.
        Specified by:
        setFlushCacheOnDeallocate in interface BaseConnection
        Parameters:
        flushCacheOnDeallocate - true if statement cache should be reset when "deallocate/discard" message observed
      • createStatement

        public java.sql.Statement createStatement()
                                           throws java.sql.SQLException
        Specified by:
        createStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql)
                                               throws java.sql.SQLException
        Specified by:
        prepareCall in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getTypeMap

        public java.util.Map<java.lang.String,​java.lang.Class<?>> getTypeMap()
                                                                            throws java.sql.SQLException
        Specified by:
        getTypeMap in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getReplicationProtocol

        public ReplicationProtocol getReplicationProtocol()
        Description copied from interface: BaseConnection
        Internal protocol for work with physical and logical replication. Physical replication available only since PostgreSQL version 9.1. Logical replication available only since PostgreSQL version 9.4.
        Specified by:
        getReplicationProtocol in interface BaseConnection
        Returns:
        not null replication protocol
      • addWarning

        public void addWarning​(java.sql.SQLWarning warn)
        This adds a warning to the warning chain.
        Parameters:
        warn - warning to add
      • execSQLQuery

        public java.sql.ResultSet execSQLQuery​(java.lang.String s)
                                        throws java.sql.SQLException
        Description copied from interface: BaseConnection
        Execute a SQL query that returns a single resultset. Never causes a new transaction to be started regardless of the autocommit setting.
        Specified by:
        execSQLQuery in interface BaseConnection
        Parameters:
        s - the query to execute
        Returns:
        the (non-null) returned resultset
        Throws:
        java.sql.SQLException - if something goes wrong.
      • execSQLQuery

        public java.sql.ResultSet execSQLQuery​(java.lang.String s,
                                               int resultSetType,
                                               int resultSetConcurrency)
                                        throws java.sql.SQLException
        Specified by:
        execSQLQuery in interface BaseConnection
        Throws:
        java.sql.SQLException
      • execSQLUpdate

        public void execSQLUpdate​(java.lang.String s)
                           throws java.sql.SQLException
        Description copied from interface: BaseConnection
        Execute a SQL query that does not return results. Never causes a new transaction to be started regardless of the autocommit setting.
        Specified by:
        execSQLUpdate in interface BaseConnection
        Parameters:
        s - the query to execute
        Throws:
        java.sql.SQLException - if something goes wrong.
      • setCursorName

        public void setCursorName​(java.lang.String cursor)
                           throws java.sql.SQLException

        In SQL, a result table can be retrieved through a cursor that is named. The current row of a result can be updated or deleted using a positioned update/delete statement that references the cursor name.

        We do not support positioned update/delete, so this is a no-op.

        Parameters:
        cursor - the cursor name
        Throws:
        java.sql.SQLException - if a database access error occurs
      • getCursorName

        public java.lang.String getCursorName()
                                       throws java.sql.SQLException
        getCursorName gets the cursor name.
        Returns:
        the current cursor name
        Throws:
        java.sql.SQLException - if a database access error occurs
      • getURL

        public java.lang.String getURL()
                                throws java.sql.SQLException

        We are required to bring back certain information by the DatabaseMetaData class. These functions do that.

        Method getURL() brings back the URL (good job we saved it)

        Returns:
        the url
        Throws:
        java.sql.SQLException - just in case...
      • getUserName

        public java.lang.String getUserName()
                                     throws java.sql.SQLException
        Method getUserName() brings back the User Name (again, we saved it).
        Returns:
        the user name
        Throws:
        java.sql.SQLException - just in case...
      • getFastpathAPI

        public Fastpath getFastpathAPI()
                                throws java.sql.SQLException
        Description copied from interface: PGConnection
        This returns the Fastpath API for the current connection.
        Specified by:
        getFastpathAPI in interface PGConnection
        Returns:
        Fastpath API for the current connection
        Throws:
        java.sql.SQLException - if something wrong happens
      • getLargeObjectAPI

        public LargeObjectManager getLargeObjectAPI()
                                             throws java.sql.SQLException
        Description copied from interface: PGConnection
        This returns the LargeObject API for the current connection.
        Specified by:
        getLargeObjectAPI in interface PGConnection
        Returns:
        LargeObject API for the current connection
        Throws:
        java.sql.SQLException - if something wrong happens
      • getObject

        public java.lang.Object getObject​(java.lang.String type,
                                          java.lang.String value,
                                          byte[] byteValue)
                                   throws java.sql.SQLException
        Description copied from interface: BaseConnection

        Construct and return an appropriate object for the given type and value. This only considers the types registered via PGConnection.addDataType(String, Class) and PGConnection.addDataType(String, String).

        If no class is registered as handling the given type, then a generic PGobject instance is returned.

        Specified by:
        getObject in interface BaseConnection
        Parameters:
        type - the backend typename
        value - the type-specific string representation of the value
        byteValue - the type-specific binary representation of the value
        Returns:
        an appropriate object; never null.
        Throws:
        java.sql.SQLException - if something goes wrong
      • addDataType

        public void addDataType​(java.lang.String type,
                                java.lang.String name)
        Description copied from interface: PGConnection
        This allows client code to add a handler for one of org.postgresql's more unique data types. It is approximately equivalent to addDataType(type, Class.forName(name)).
        Specified by:
        addDataType in interface PGConnection
        Parameters:
        type - JDBC type name
        name - class name
      • addDataType

        public void addDataType​(java.lang.String type,
                                java.lang.Class<? extends PGobject> klass)
                         throws java.sql.SQLException
        Description copied from interface: PGConnection

        This allows client code to add a handler for one of org.postgresql's more unique data types.

        NOTE: This is not part of JDBC, but an extension.

        The best way to use this is as follows:

         ...
         ((org.postgresql.PGConnection)myconn).addDataType("mytype", my.class.name.class);
         ...
         

        where myconn is an open Connection to org.postgresql.

        The handling class must extend org.postgresql.util.PGobject

        Specified by:
        addDataType in interface PGConnection
        Parameters:
        type - the PostgreSQL type to register
        klass - the class implementing the Java representation of the type; this class must implement PGobject).
        Throws:
        java.sql.SQLException - if klass does not implement PGobject).
        See Also:
        PGobject
      • close

        public void close()
                   throws java.sql.SQLException
        Note: even though Statement is automatically closed when it is garbage collected, it is better to close it explicitly to lower resource consumption.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • nativeSQL

        public java.lang.String nativeSQL​(java.lang.String sql)
                                   throws java.sql.SQLException
        Specified by:
        nativeSQL in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getWarnings

        public java.sql.SQLWarning getWarnings()
                                        throws java.sql.SQLException
        Specified by:
        getWarnings in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • clearWarnings

        public void clearWarnings()
                           throws java.sql.SQLException
        Specified by:
        clearWarnings in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setReadOnly

        public void setReadOnly​(boolean readOnly)
                         throws java.sql.SQLException
        Specified by:
        setReadOnly in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • isReadOnly

        public boolean isReadOnly()
                           throws java.sql.SQLException
        Specified by:
        isReadOnly in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • hintReadOnly

        public boolean hintReadOnly()
        Description copied from interface: BaseConnection
        Indicates if statements to backend should be hinted as read only.
        Specified by:
        hintReadOnly in interface BaseConnection
        Returns:
        Indication if hints to backend (such as when transaction begins) should be read only.
        See Also:
        PGProperty.READ_ONLY_MODE
      • setAutoCommit

        public void setAutoCommit​(boolean autoCommit)
                           throws java.sql.SQLException
        Specified by:
        setAutoCommit in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getAutoCommit

        public boolean getAutoCommit()
                              throws java.sql.SQLException
        Specified by:
        getAutoCommit in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • commit

        public void commit()
                    throws java.sql.SQLException
        Specified by:
        commit in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • checkClosed

        protected void checkClosed()
                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • rollback

        public void rollback()
                      throws java.sql.SQLException
        Specified by:
        rollback in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getTransactionIsolation

        public int getTransactionIsolation()
                                    throws java.sql.SQLException
        Specified by:
        getTransactionIsolation in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setTransactionIsolation

        public void setTransactionIsolation​(int level)
                                     throws java.sql.SQLException
        Specified by:
        setTransactionIsolation in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getIsolationLevelName

        protected java.lang.String getIsolationLevelName​(int level)
      • setCatalog

        public void setCatalog​(java.lang.String catalog)
                        throws java.sql.SQLException
        Specified by:
        setCatalog in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getCatalog

        public java.lang.String getCatalog()
                                    throws java.sql.SQLException
        Specified by:
        getCatalog in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getHideUnprivilegedObjects

        public boolean getHideUnprivilegedObjects()
      • finalize

        protected void finalize()
                         throws java.lang.Throwable

        Overrides finalize(). If called, it closes the connection.

        This was done at the request of Rachel Greenham who hit a problem where multiple clients didn't close the connection, and once a fortnight enough clients were open to kill the postgres server.

        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • getDBVersionNumber

        public java.lang.String getDBVersionNumber()
        Get server version number.
        Returns:
        server version number
      • getServerMajorVersion

        public int getServerMajorVersion()
        Get server major version.
        Returns:
        server major version
      • getServerMinorVersion

        public int getServerMinorVersion()
        Get server minor version.
        Returns:
        server minor version
      • haveMinimumServerVersion

        public boolean haveMinimumServerVersion​(int ver)
        Description copied from interface: BaseConnection

        Check if we have at least a particular server version.

        The input version is of the form xxyyzz, matching a PostgreSQL version like xx.yy.zz. So 9.0.12 is 90012.

        Specified by:
        haveMinimumServerVersion in interface BaseConnection
        Parameters:
        ver - the server version to check, of the form xxyyzz eg 90401
        Returns:
        true if the server version is at least "ver".
      • haveMinimumServerVersion

        public boolean haveMinimumServerVersion​(Version ver)
        Description copied from interface: BaseConnection

        Check if we have at least a particular server version.

        The input version is of the form xxyyzz, matching a PostgreSQL version like xx.yy.zz. So 9.0.12 is 90012.

        Specified by:
        haveMinimumServerVersion in interface BaseConnection
        Parameters:
        ver - the server version to check
        Returns:
        true if the server version is at least "ver".
      • encodeString

        public byte[] encodeString​(java.lang.String str)
                            throws java.sql.SQLException
        Description copied from interface: BaseConnection
        Encode a string using the database's client_encoding (usually UTF8, but can vary on older server versions). This is used when constructing synthetic resultsets (for example, in metadata methods).
        Specified by:
        encodeString in interface BaseConnection
        Parameters:
        str - the string to encode
        Returns:
        an encoded representation of the string
        Throws:
        java.sql.SQLException - if something goes wrong.
      • escapeString

        public java.lang.String escapeString​(java.lang.String str)
                                      throws java.sql.SQLException
        Description copied from interface: BaseConnection
        Escapes a string for use as string-literal within an SQL command. The method chooses the applicable escaping rules based on the value of BaseConnection.getStandardConformingStrings().
        Specified by:
        escapeString in interface BaseConnection
        Parameters:
        str - a string value
        Returns:
        the escaped representation of the string
        Throws:
        java.sql.SQLException - if the string contains a \0 character
      • getStandardConformingStrings

        public boolean getStandardConformingStrings()
        Description copied from interface: BaseConnection
        Returns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules. Versions up to 8.1 always treated backslashes as escape characters in string-literals. Since 8.2, this depends on the value of the standard_conforming_strings server variable.
        Specified by:
        getStandardConformingStrings in interface BaseConnection
        Returns:
        true if the server treats string literals according to the SQL standard
        See Also:
        QueryExecutor.getStandardConformingStrings()
      • isClosed

        public boolean isClosed()
                         throws java.sql.SQLException
        Specified by:
        isClosed in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • cancelQuery

        public void cancelQuery()
                         throws java.sql.SQLException
        Description copied from interface: BaseConnection
        Cancel the current query executing on this connection.
        Specified by:
        cancelQuery in interface BaseConnection
        Specified by:
        cancelQuery in interface PGConnection
        Throws:
        java.sql.SQLException - if something goes wrong.
      • getNotifications

        public PGNotification[] getNotifications()
                                          throws java.sql.SQLException
        Description copied from interface: PGConnection
        This method returns any notifications that have been received since the last call to this method. Returns null if there have been no notifications.
        Specified by:
        getNotifications in interface PGConnection
        Returns:
        notifications that have been received
        Throws:
        java.sql.SQLException - if something wrong happens
      • getNotifications

        public PGNotification[] getNotifications​(int timeoutMillis)
                                          throws java.sql.SQLException
        Description copied from interface: PGConnection
        This method returns any notifications that have been received since the last call to this method. Returns null if there have been no notifications. A timeout can be specified so the driver waits for notifications.
        Specified by:
        getNotifications in interface PGConnection
        Parameters:
        timeoutMillis - when 0, blocks forever. when > 0, blocks up to the specified number of millies or until at least one notification has been received. If more than one notification is about to be received, these will be returned in one batch.
        Returns:
        notifications that have been received
        Throws:
        java.sql.SQLException - if something wrong happens
      • getPrepareThreshold

        public int getPrepareThreshold()
        Description copied from interface: PGConnection
        Get the default server-side prepare reuse threshold for statements created from this connection.
        Specified by:
        getPrepareThreshold in interface PGConnection
        Returns:
        the current threshold
      • setDefaultFetchSize

        public void setDefaultFetchSize​(int fetchSize)
                                 throws java.sql.SQLException
        Description copied from interface: PGConnection
        Set the default fetch size for statements created from this connection.
        Specified by:
        setDefaultFetchSize in interface PGConnection
        Parameters:
        fetchSize - new default fetch size
        Throws:
        java.sql.SQLException - if specified negative fetchSize parameter
        See Also:
        Statement.setFetchSize(int)
      • getForceBinary

        public boolean getForceBinary()
      • setForceBinary

        public void setForceBinary​(boolean newValue)
      • setTypeMapImpl

        public void setTypeMapImpl​(java.util.Map<java.lang.String,​java.lang.Class<?>> map)
                            throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getProtocolVersion

        public int getProtocolVersion()
      • getCopyAPI

        public CopyManager getCopyAPI()
                               throws java.sql.SQLException
        Description copied from interface: PGConnection
        This returns the COPY API for the current connection.
        Specified by:
        getCopyAPI in interface PGConnection
        Returns:
        COPY API for the current connection
        Throws:
        java.sql.SQLException - if something wrong happens
      • binaryTransferSend

        public boolean binaryTransferSend​(int oid)
        Description copied from interface: BaseConnection
        Returns true if value for the given oid should be sent using binary transfer. False if value should be sent using text transfer.
        Specified by:
        binaryTransferSend in interface BaseConnection
        Parameters:
        oid - The oid to check.
        Returns:
        True for binary transfer, false for text transfer.
      • getBackendPID

        public int getBackendPID()
        Description copied from interface: PGConnection
        Return the process ID (PID) of the backend server process handling this connection.
        Specified by:
        getBackendPID in interface PGConnection
        Returns:
        PID of backend server process.
      • isColumnSanitiserDisabled

        public boolean isColumnSanitiserDisabled()
        Description copied from interface: BaseConnection
        Return whether to disable column name sanitation.
        Specified by:
        isColumnSanitiserDisabled in interface BaseConnection
        Returns:
        true column sanitizer is disabled
      • setDisableColumnSanitiser

        public void setDisableColumnSanitiser​(boolean disableColumnSanitiser)
      • getPreferQueryMode

        public PreferQueryMode getPreferQueryMode()
        Description copied from interface: PGConnection

        Returns the query mode for this connection.

        When running in simple query mode, certain features are not available: callable statements, partial result set fetch, bytea type, etc.

        The list of supported features is subject to change.

        Specified by:
        getPreferQueryMode in interface PGConnection
        Returns:
        the preferred query mode
        See Also:
        PreferQueryMode
      • getAutosave

        public AutoSave getAutosave()
        Description copied from interface: PGConnection
        Connection configuration regarding automatic per-query savepoints.
        Specified by:
        getAutosave in interface PGConnection
        Returns:
        connection configuration regarding automatic per-query savepoints
        See Also:
        PGProperty.AUTOSAVE
      • setAutosave

        public void setAutosave​(AutoSave autoSave)
        Description copied from interface: PGConnection
        Configures if connection should use automatic savepoints.
        Specified by:
        setAutosave in interface PGConnection
        Parameters:
        autoSave - connection configuration regarding automatic per-query savepoints
        See Also:
        PGProperty.AUTOSAVE
      • abort

        protected void abort()
      • addTimerTask

        public void addTimerTask​(java.util.TimerTask timerTask,
                                 long milliSeconds)
        Description copied from interface: BaseConnection
        Schedule a TimerTask for later execution. The task will be scheduled with the shared Timer for this connection.
        Specified by:
        addTimerTask in interface BaseConnection
        Parameters:
        timerTask - timer task to schedule
        milliSeconds - delay in milliseconds
      • purgeTimerTasks

        public void purgeTimerTasks()
        Description copied from interface: BaseConnection
        Invoke purge() on the underlying shared Timer so that internal resources will be released.
        Specified by:
        purgeTimerTasks in interface BaseConnection
      • escapeIdentifier

        public java.lang.String escapeIdentifier​(java.lang.String identifier)
                                          throws java.sql.SQLException
        Description copied from interface: PGConnection
        Return the given string suitably quoted to be used as an identifier in an SQL statement string. Quotes are added only if necessary (i.e., if the string contains non-identifier characters or would be case-folded). Embedded quotes are properly doubled.
        Specified by:
        escapeIdentifier in interface PGConnection
        Parameters:
        identifier - input identifier
        Returns:
        the escaped identifier
        Throws:
        java.sql.SQLException - if something goes wrong
      • escapeLiteral

        public java.lang.String escapeLiteral​(java.lang.String literal)
                                       throws java.sql.SQLException
        Description copied from interface: PGConnection
        Return the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal returns null on null input.
        Specified by:
        escapeLiteral in interface PGConnection
        Parameters:
        literal - input literal
        Returns:
        the quoted literal
        Throws:
        java.sql.SQLException - if something goes wrong
      • createStatement

        public java.sql.Statement createStatement​(int resultSetType,
                                                  int resultSetConcurrency,
                                                  int resultSetHoldability)
                                           throws java.sql.SQLException
        Specified by:
        createStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int resultSetType,
                                                           int resultSetConcurrency,
                                                           int resultSetHoldability)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql,
                                                      int resultSetType,
                                                      int resultSetConcurrency,
                                                      int resultSetHoldability)
                                               throws java.sql.SQLException
        Specified by:
        prepareCall in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getMetaData

        public java.sql.DatabaseMetaData getMetaData()
                                              throws java.sql.SQLException
        Specified by:
        getMetaData in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setTypeMap

        public void setTypeMap​(java.util.Map<java.lang.String,​java.lang.Class<?>> map)
                        throws java.sql.SQLException
        Specified by:
        setTypeMap in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • makeArray

        protected java.sql.Array makeArray​(int oid,
                                           java.lang.String fieldString)
                                    throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • makeBlob

        protected java.sql.Blob makeBlob​(long oid)
                                  throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • makeClob

        protected java.sql.Clob makeClob​(long oid)
                                  throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • makeSQLXML

        protected java.sql.SQLXML makeSQLXML()
                                      throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • createClob

        public java.sql.Clob createClob()
                                 throws java.sql.SQLException
        Specified by:
        createClob in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createBlob

        public java.sql.Blob createBlob()
                                 throws java.sql.SQLException
        Specified by:
        createBlob in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createNClob

        public java.sql.NClob createNClob()
                                   throws java.sql.SQLException
        Specified by:
        createNClob in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createSQLXML

        public java.sql.SQLXML createSQLXML()
                                     throws java.sql.SQLException
        Specified by:
        createSQLXML in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createStruct

        public java.sql.Struct createStruct​(java.lang.String typeName,
                                            java.lang.Object[] attributes)
                                     throws java.sql.SQLException
        Specified by:
        createStruct in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createArrayOf

        public java.sql.Array createArrayOf​(java.lang.String typeName,
                                            java.lang.Object elements)
                                     throws java.sql.SQLException
        Description copied from interface: PGConnection
        Creates an Array wrapping elements. This is similar to Connection.createArrayOf(String, Object[]), but also provides support for primitive arrays.
        Specified by:
        createArrayOf in interface PGConnection
        Parameters:
        typeName - The SQL name of the type to map the elements to. Must not be null.
        elements - The array of objects to map. A null value will result in an Array representing null.
        Returns:
        An Array wrapping elements.
        Throws:
        java.sql.SQLException - If for some reason the array cannot be created.
        See Also:
        Connection.createArrayOf(String, Object[])
      • createArrayOf

        public java.sql.Array createArrayOf​(java.lang.String typeName,
                                            java.lang.Object[] elements)
                                     throws java.sql.SQLException
        Specified by:
        createArrayOf in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • isValid

        public boolean isValid​(int timeout)
                        throws java.sql.SQLException
        Specified by:
        isValid in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setClientInfo

        public void setClientInfo​(java.lang.String name,
                                  java.lang.String value)
                           throws java.sql.SQLClientInfoException
        Specified by:
        setClientInfo in interface java.sql.Connection
        Throws:
        java.sql.SQLClientInfoException
      • setClientInfo

        public void setClientInfo​(java.util.Properties properties)
                           throws java.sql.SQLClientInfoException
        Specified by:
        setClientInfo in interface java.sql.Connection
        Throws:
        java.sql.SQLClientInfoException
      • getClientInfo

        public java.lang.String getClientInfo​(java.lang.String name)
                                       throws java.sql.SQLException
        Specified by:
        getClientInfo in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getClientInfo

        public java.util.Properties getClientInfo()
                                           throws java.sql.SQLException
        Specified by:
        getClientInfo in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createQueryObject

        public <T> T createQueryObject​(java.lang.Class<T> ifc)
                                throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • isWrapperFor

        public boolean isWrapperFor​(java.lang.Class<?> iface)
                             throws java.sql.SQLException
        Specified by:
        isWrapperFor in interface java.sql.Wrapper
        Throws:
        java.sql.SQLException
      • unwrap

        public <T> T unwrap​(java.lang.Class<T> iface)
                     throws java.sql.SQLException
        Specified by:
        unwrap in interface java.sql.Wrapper
        Throws:
        java.sql.SQLException
      • getSchema

        public java.lang.String getSchema()
                                   throws java.sql.SQLException
        Specified by:
        getSchema in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setSchema

        public void setSchema​(java.lang.String schema)
                       throws java.sql.SQLException
        Specified by:
        setSchema in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • abort

        public void abort​(java.util.concurrent.Executor executor)
                   throws java.sql.SQLException
        Specified by:
        abort in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setNetworkTimeout

        public void setNetworkTimeout​(java.util.concurrent.Executor executor,
                                      int milliseconds)
                               throws java.sql.SQLException
        Specified by:
        setNetworkTimeout in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getNetworkTimeout

        public int getNetworkTimeout()
                              throws java.sql.SQLException
        Specified by:
        getNetworkTimeout in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setHoldability

        public void setHoldability​(int holdability)
                            throws java.sql.SQLException
        Specified by:
        setHoldability in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getHoldability

        public int getHoldability()
                           throws java.sql.SQLException
        Specified by:
        getHoldability in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setSavepoint

        public java.sql.Savepoint setSavepoint()
                                        throws java.sql.SQLException
        Specified by:
        setSavepoint in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • setSavepoint

        public java.sql.Savepoint setSavepoint​(java.lang.String name)
                                        throws java.sql.SQLException
        Specified by:
        setSavepoint in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • rollback

        public void rollback​(java.sql.Savepoint savepoint)
                      throws java.sql.SQLException
        Specified by:
        rollback in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • releaseSavepoint

        public void releaseSavepoint​(java.sql.Savepoint savepoint)
                              throws java.sql.SQLException
        Specified by:
        releaseSavepoint in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • createStatement

        public java.sql.Statement createStatement​(int resultSetType,
                                                  int resultSetConcurrency)
                                           throws java.sql.SQLException
        Specified by:
        createStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int resultSetType,
                                                           int resultSetConcurrency)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql,
                                                      int resultSetType,
                                                      int resultSetConcurrency)
                                               throws java.sql.SQLException
        Specified by:
        prepareCall in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int autoGeneratedKeys)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int[] columnIndexes)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           java.lang.String[] columnNames)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Throws:
        java.sql.SQLException
      • getParameterStatuses

        public final java.util.Map<java.lang.String,​java.lang.String> getParameterStatuses()
        Description copied from interface: PGConnection

        Returns the current values of all parameters reported by the server.

        PostgreSQL reports values for a subset of parameters (GUCs) to the client at connect-time, then sends update messages whenever the values change during a session. PgJDBC records the latest values and exposes it to client applications via getParameterStatuses().

        PgJDBC exposes individual accessors for some of these parameters as listed below. They are more backwarrds-compatible and should be preferred where possible.

        Not all parameters are reported, only those marked GUC_REPORT in the source code. The pg_settings view does not expose information about which parameters are reportable. PgJDBC's map will only contain the parameters the server reports values for, so you cannot use this method as a substitute for running a SHOW paramname; or SELECT current_setting('paramname'); query for arbitrary parameters.

        Parameter names are case-insensitive and case-preserving in this map, like in PostgreSQL itself. So DateStyle and datestyle are the same key.

        As of PostgreSQL 11 the reportable parameter list, and related PgJDBC interfaces or accesors, are:

        • application_name - Connection.getClientInfo(), Connection.setClientInfo(java.util.Properties) and ApplicationName connection property.
        • client_encoding - PgJDBC always sets this to UTF8. See allowEncodingChanges connection property.
        • DateStyle - PgJDBC requires this to always be set to ISO
        • standard_conforming_strings - indirectly via PGConnection.escapeLiteral(String)
        • TimeZone - set from JDK timezone see TimeZone.getDefault() and TimeZone.setDefault(TimeZone)
        • integer_datetimes
        • IntervalStyle
        • server_encoding
        • server_version
        • is_superuser
        • session_authorization

        Note that some PgJDBC operations will change server parameters automatically.

        Specified by:
        getParameterStatuses in interface PGConnection
        Returns:
        unmodifiable map of case-insensitive parameter names to parameter values
      • getParameterStatus

        public final java.lang.String getParameterStatus​(java.lang.String parameterName)
        Description copied from interface: PGConnection
        Shorthand for getParameterStatuses().get(...) .
        Specified by:
        getParameterStatus in interface PGConnection
        Parameters:
        parameterName - case-insensitive parameter name
        Returns:
        parameter value if defined, or null if no parameter known
        See Also:
        PGConnection.getParameterStatuses()