Package com.impossibl.postgres.jdbc
Class PGDirectConnection
- java.lang.Object
-
- com.impossibl.postgres.system.AbstractContext
-
- com.impossibl.postgres.system.BasicContext
-
- com.impossibl.postgres.jdbc.PGDirectConnection
-
- All Implemented Interfaces:
PGConnection
,Configuration
,Context
,java.lang.AutoCloseable
,java.sql.Connection
,java.sql.Wrapper
public class PGDirectConnection extends BasicContext implements PGConnection
Direct connection implementation
-
-
Field Summary
-
Fields inherited from class com.impossibl.postgres.system.BasicContext
charset, registry, serverConnection, settings, typeMap
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort(java.util.concurrent.Executor executor)
void
addNotificationListener(PGNotificationListener listener)
Adds an, unnamed, unfiltered, asynchronous notification listener to this connectionvoid
addNotificationListener(java.lang.String channelNameFilter, PGNotificationListener listener)
Adds an, unnamed, filtered, asynchronous notification listener to this connectionvoid
addNotificationListener(java.lang.String name, java.lang.String channelNameFilter, PGNotificationListener listener)
Adds a filtered asynchronous notification listener to this connectionvoid
clearWarnings()
void
close()
void
commit()
protected void
connectionClosed()
Called whenBasicContext.serverConnection
was closed externally (i.e.protected void
connectionNotificationReceived(int processId, java.lang.String channelName, java.lang.String payload)
Called whenBasicContext.serverConnection
received an asynchronous notificationjava.sql.Array
createArrayOf(java.lang.String typeName, java.lang.Object[] elements)
java.sql.Blob
createBlob()
java.sql.Clob
createClob()
java.sql.NClob
createNClob()
java.sql.SQLXML
createSQLXML()
com.impossibl.postgres.jdbc.PGStatement
createStatement()
com.impossibl.postgres.jdbc.PGStatement
createStatement(int resultSetType, int resultSetConcurrency)
com.impossibl.postgres.jdbc.PGStatement
createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
java.sql.Struct
createStruct(java.lang.String typeName, java.lang.Object[] attributes)
boolean
getAutoCommit()
java.lang.String
getCatalog()
java.util.Properties
getClientInfo()
java.lang.String
getClientInfo(java.lang.String name)
java.lang.Integer
getDefaultFetchSize()
Get the default fetch sizeint
getHoldability()
java.sql.DatabaseMetaData
getMetaData()
int
getNetworkTimeout()
java.lang.String
getSchema()
int
getTransactionIsolation()
TransactionStatus
getTransactionStatus()
java.util.Map<java.lang.String,java.lang.Class<?>>
getTypeMap()
java.sql.SQLWarning
getWarnings()
void
init(SharedRegistry.Factory sharedRegistryFactory)
boolean
isClosed()
boolean
isReadOnly()
boolean
isServerMinimumVersion(int major, int minor)
Checks the minimum server versionboolean
isStrictMode()
Is strict modeboolean
isValid(int timeout)
boolean
isWrapperFor(java.lang.Class<?> iface)
java.lang.String
nativeSQL(java.lang.String sql)
java.sql.CallableStatement
prepareCall(java.lang.String sql)
java.sql.CallableStatement
prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
java.sql.CallableStatement
prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
com.impossibl.postgres.jdbc.PGPreparedStatement
prepareStatement(SQLText sqlText, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
com.impossibl.postgres.jdbc.PGPreparedStatement
prepareStatement(java.lang.String sql)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, int autoGeneratedKeys)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, int[] columnIndexes)
com.impossibl.postgres.jdbc.PGPreparedStatement
prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
com.impossibl.postgres.jdbc.PGPreparedStatement
prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
java.sql.PreparedStatement
prepareStatement(java.lang.String sql, java.lang.String[] columnNames)
void
releaseSavepoint(java.sql.Savepoint savepointParam)
void
removeNotificationListener(PGNotificationListener listener)
Removes a notification listenervoid
removeNotificationListener(java.lang.String listenerName)
Removes a named notification listenerPGAnyType
resolveType(java.lang.String name)
Resolves a name to an SQLType suitable for passing to any method that accepts one.void
rollback()
void
rollback(java.sql.Savepoint savepointParam)
void
setAutoCommit(boolean autoCommit)
void
setCatalog(java.lang.String catalog)
void
setClientInfo(java.lang.String name, java.lang.String value)
void
setClientInfo(java.util.Properties properties)
void
setDefaultFetchSize(java.lang.Integer v)
Set the default fetch sizevoid
setHoldability(int holdability)
void
setNetworkTimeout(java.util.concurrent.Executor executor, int networkTimeout)
void
setReadOnly(boolean readOnly)
java.sql.Savepoint
setSavepoint()
java.sql.Savepoint
setSavepoint(java.lang.String name)
void
setSchema(java.lang.String schema)
void
setStrictMode(boolean v)
Set strict modevoid
setTransactionIsolation(int level)
void
setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> typeMap)
<T> T
unwrap(java.lang.Class<T> iface)
-
Methods inherited from class com.impossibl.postgres.system.BasicContext
getAllocator, getCharset, getCurrencyFormatter, getCustomTypeMap, getDateFormat, getDecimalFormatter, getIntegerFormatter, getKeyData, getRegistry, getRequestExecutor, getServerInfo, getSetting, getTimeFormat, getTimestampFormat, getTimeZone, getTimeZoneId, isUtilQueryPrepared, prepareUtilQuery, query, queryBatch, queryBatchPrepared, queryBatchPrepared, queryString, shutdown, unwrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.impossibl.postgres.system.Configuration
getSetting
-
-
-
-
Method Detail
-
init
public void init(SharedRegistry.Factory sharedRegistryFactory) throws java.io.IOException
- Overrides:
init
in classBasicContext
- Throws:
java.io.IOException
-
getTransactionStatus
public TransactionStatus getTransactionStatus() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
setStrictMode
public void setStrictMode(boolean v)
Set strict mode- Specified by:
setStrictMode
in interfacePGConnection
- Parameters:
v
- The value
-
isStrictMode
public boolean isStrictMode()
Is strict mode- Specified by:
isStrictMode
in interfacePGConnection
- Returns:
- The value
-
setDefaultFetchSize
public void setDefaultFetchSize(java.lang.Integer v)
Set the default fetch size- Specified by:
setDefaultFetchSize
in interfacePGConnection
- Parameters:
v
- The value
-
getDefaultFetchSize
public java.lang.Integer getDefaultFetchSize()
Get the default fetch size- Specified by:
getDefaultFetchSize
in interfacePGConnection
- Returns:
- The value
-
resolveType
public PGAnyType resolveType(java.lang.String name) throws java.sql.SQLException
Description copied from interface:PGConnection
Resolves a name to an SQLType suitable for passing to any method that accepts one. As the method queries the server for the type information any type name acceptable to the server is allowed (i.e. qualified, unqualified, quoted, etc.) Using this method allows the resolution of a name to a type to be re-used; speeding up performance in cases where named types are used. NOTE: The possibility of DDL changing the name to type mapping means named types are always looked up when used. This ensures that the correct type is used always. When resolving a named type using this method it is only valid as long as no commands are issued that invalidate it (e.g. dropping and re-adding a type or extension).- Specified by:
resolveType
in interfacePGConnection
- Parameters:
name
- Name of type to resolve (anything acceptable to the server)- Returns:
- Type instance representing the current name to type mapping.
- Throws:
java.sql.SQLException
-
connectionClosed
protected void connectionClosed()
Description copied from class:BasicContext
Called whenBasicContext.serverConnection
was closed externally (i.e. without callingBasicContext.shutdown()
- Overrides:
connectionClosed
in classBasicContext
-
isServerMinimumVersion
public boolean isServerMinimumVersion(int major, int minor)
Checks the minimum server version- Specified by:
isServerMinimumVersion
in interfacePGConnection
- Parameters:
major
- The major releaseminor
- The minor release- Returns:
True
if the server is minimum the specified version, otherwisefalse
.
-
isValid
public boolean isValid(int timeout) throws java.sql.SQLException
- Specified by:
isValid
in interfacejava.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 interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setTypeMap
public void setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> typeMap) throws java.sql.SQLException
- Specified by:
setTypeMap
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getHoldability
public int getHoldability() throws java.sql.SQLException
- Specified by:
getHoldability
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setHoldability
public void setHoldability(int holdability) throws java.sql.SQLException
- Specified by:
setHoldability
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getMetaData
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
- Specified by:
getMetaData
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getAutoCommit
public boolean getAutoCommit() throws java.sql.SQLException
- Specified by:
getAutoCommit
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException
- Specified by:
setAutoCommit
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
isReadOnly
public boolean isReadOnly() throws java.sql.SQLException
- Specified by:
isReadOnly
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws java.sql.SQLException
- Specified by:
setReadOnly
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getTransactionIsolation
public int getTransactionIsolation() throws java.sql.SQLException
- Specified by:
getTransactionIsolation
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws java.sql.SQLException
- Specified by:
setTransactionIsolation
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
commit
public void commit() throws java.sql.SQLException
- Specified by:
commit
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
rollback
public void rollback() throws java.sql.SQLException
- Specified by:
rollback
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException
- Specified by:
setSavepoint
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException
- Specified by:
setSavepoint
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
rollback
public void rollback(java.sql.Savepoint savepointParam) throws java.sql.SQLException
- Specified by:
rollback
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
releaseSavepoint
public void releaseSavepoint(java.sql.Savepoint savepointParam) throws java.sql.SQLException
- Specified by:
releaseSavepoint
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getCatalog
public java.lang.String getCatalog() throws java.sql.SQLException
- Specified by:
getCatalog
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setCatalog
public void setCatalog(java.lang.String catalog) throws java.sql.SQLException
- Specified by:
setCatalog
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getSchema
public java.lang.String getSchema() throws java.sql.SQLException
- Specified by:
getSchema
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setSchema
public void setSchema(java.lang.String schema) throws java.sql.SQLException
- Specified by:
setSchema
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
nativeSQL
public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLException
- Specified by:
nativeSQL
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createStatement
public com.impossibl.postgres.jdbc.PGStatement createStatement() throws java.sql.SQLException
- Specified by:
createStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createStatement
public com.impossibl.postgres.jdbc.PGStatement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
- Specified by:
createStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createStatement
public com.impossibl.postgres.jdbc.PGStatement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
- Specified by:
createStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareStatement
public com.impossibl.postgres.jdbc.PGPreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareStatement
public com.impossibl.postgres.jdbc.PGPreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareStatement
public com.impossibl.postgres.jdbc.PGPreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareStatement
public com.impossibl.postgres.jdbc.PGPreparedStatement prepareStatement(SQLText sqlText, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
prepareStatement
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
- Specified by:
prepareStatement
in interfacejava.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 interfacejava.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 interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
- Specified by:
prepareCall
in interfacejava.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 interfacejava.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 interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createBlob
public java.sql.Blob createBlob() throws java.sql.SQLException
- Specified by:
createBlob
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createClob
public java.sql.Clob createClob() throws java.sql.SQLException
- Specified by:
createClob
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createSQLXML
public java.sql.SQLXML createSQLXML() throws java.sql.SQLException
- Specified by:
createSQLXML
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
createArrayOf
public java.sql.Array createArrayOf(java.lang.String typeName, java.lang.Object[] elements) throws java.sql.SQLException
- Specified by:
createArrayOf
in interfacejava.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 interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getClientInfo
public java.lang.String getClientInfo(java.lang.String name) throws java.sql.SQLException
- Specified by:
getClientInfo
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getClientInfo
public java.util.Properties getClientInfo() throws java.sql.SQLException
- Specified by:
getClientInfo
in interfacejava.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 interfacejava.sql.Connection
- Throws:
java.sql.SQLClientInfoException
-
setClientInfo
public void setClientInfo(java.util.Properties properties) throws java.sql.SQLClientInfoException
- Specified by:
setClientInfo
in interfacejava.sql.Connection
- Throws:
java.sql.SQLClientInfoException
-
createNClob
public java.sql.NClob createNClob() throws java.sql.SQLException
- Specified by:
createNClob
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
isClosed
public boolean isClosed()
- Specified by:
isClosed
in interfacejava.sql.Connection
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.sql.Connection
-
abort
public void abort(java.util.concurrent.Executor executor)
- Specified by:
abort
in interfacejava.sql.Connection
-
getWarnings
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
- Specified by:
getWarnings
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
clearWarnings
public void clearWarnings() throws java.sql.SQLException
- Specified by:
clearWarnings
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws java.sql.SQLException
- Specified by:
getNetworkTimeout
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
setNetworkTimeout
public void setNetworkTimeout(java.util.concurrent.Executor executor, int networkTimeout) throws java.sql.SQLException
- Specified by:
setNetworkTimeout
in interfacejava.sql.Connection
- Throws:
java.sql.SQLException
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
- Specified by:
unwrap
in interfacejava.sql.Wrapper
- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface)
- Specified by:
isWrapperFor
in interfacejava.sql.Wrapper
-
connectionNotificationReceived
protected void connectionNotificationReceived(int processId, java.lang.String channelName, java.lang.String payload)
Description copied from class:BasicContext
Called whenBasicContext.serverConnection
received an asynchronous notification- Overrides:
connectionNotificationReceived
in classBasicContext
-
addNotificationListener
public void addNotificationListener(PGNotificationListener listener)
Description copied from interface:PGConnection
Adds an, unnamed, unfiltered, asynchronous notification listener to this connection- Specified by:
addNotificationListener
in interfacePGConnection
- Parameters:
listener
- Notification listener
-
addNotificationListener
public void addNotificationListener(java.lang.String channelNameFilter, PGNotificationListener listener)
Description copied from interface:PGConnection
Adds an, unnamed, filtered, asynchronous notification listener to this connection- Specified by:
addNotificationListener
in interfacePGConnection
- Parameters:
channelNameFilter
- Channel name based notification filter (Regular Expression)listener
- Notification listener
-
addNotificationListener
public void addNotificationListener(java.lang.String name, java.lang.String channelNameFilter, PGNotificationListener listener)
Description copied from interface:PGConnection
Adds a filtered asynchronous notification listener to this connection- Specified by:
addNotificationListener
in interfacePGConnection
- Parameters:
name
- Name of listenerchannelNameFilter
- Channel name based notification filter (Regular Expression)listener
- Notification listener
-
removeNotificationListener
public void removeNotificationListener(PGNotificationListener listener)
Description copied from interface:PGConnection
Removes a notification listener- Specified by:
removeNotificationListener
in interfacePGConnection
- Parameters:
listener
- Listener instance to remove
-
removeNotificationListener
public void removeNotificationListener(java.lang.String listenerName)
Description copied from interface:PGConnection
Removes a named notification listener- Specified by:
removeNotificationListener
in interfacePGConnection
- Parameters:
listenerName
- Name of listener to remove
-
-