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 voidabort(java.util.concurrent.Executor executor)voidaddNotificationListener(PGNotificationListener listener)Adds an, unnamed, unfiltered, asynchronous notification listener to this connectionvoidaddNotificationListener(java.lang.String channelNameFilter, PGNotificationListener listener)Adds an, unnamed, filtered, asynchronous notification listener to this connectionvoidaddNotificationListener(java.lang.String name, java.lang.String channelNameFilter, PGNotificationListener listener)Adds a filtered asynchronous notification listener to this connectionvoidclearWarnings()voidclose()voidcommit()protected voidconnectionClosed()Called whenBasicContext.serverConnectionwas closed externally (i.e.protected voidconnectionNotificationReceived(int processId, java.lang.String channelName, java.lang.String payload)Called whenBasicContext.serverConnectionreceived an asynchronous notificationjava.sql.ArraycreateArrayOf(java.lang.String typeName, java.lang.Object[] elements)java.sql.BlobcreateBlob()java.sql.ClobcreateClob()java.sql.NClobcreateNClob()java.sql.SQLXMLcreateSQLXML()com.impossibl.postgres.jdbc.PGStatementcreateStatement()com.impossibl.postgres.jdbc.PGStatementcreateStatement(int resultSetType, int resultSetConcurrency)com.impossibl.postgres.jdbc.PGStatementcreateStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)java.sql.StructcreateStruct(java.lang.String typeName, java.lang.Object[] attributes)booleangetAutoCommit()java.lang.StringgetCatalog()java.util.PropertiesgetClientInfo()java.lang.StringgetClientInfo(java.lang.String name)java.lang.IntegergetDefaultFetchSize()Get the default fetch sizeintgetHoldability()java.sql.DatabaseMetaDatagetMetaData()intgetNetworkTimeout()java.lang.StringgetSchema()intgetTransactionIsolation()TransactionStatusgetTransactionStatus()java.util.Map<java.lang.String,java.lang.Class<?>>getTypeMap()java.sql.SQLWarninggetWarnings()voidinit(SharedRegistry.Factory sharedRegistryFactory)booleanisClosed()booleanisReadOnly()booleanisServerMinimumVersion(int major, int minor)Checks the minimum server versionbooleanisStrictMode()Is strict modebooleanisValid(int timeout)booleanisWrapperFor(java.lang.Class<?> iface)java.lang.StringnativeSQL(java.lang.String sql)java.sql.CallableStatementprepareCall(java.lang.String sql)java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)java.sql.CallableStatementprepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)com.impossibl.postgres.jdbc.PGPreparedStatementprepareStatement(SQLText sqlText, int resultSetType, int resultSetConcurrency, int resultSetHoldability)com.impossibl.postgres.jdbc.PGPreparedStatementprepareStatement(java.lang.String sql)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int autoGeneratedKeys)java.sql.PreparedStatementprepareStatement(java.lang.String sql, int[] columnIndexes)com.impossibl.postgres.jdbc.PGPreparedStatementprepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)com.impossibl.postgres.jdbc.PGPreparedStatementprepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)java.sql.PreparedStatementprepareStatement(java.lang.String sql, java.lang.String[] columnNames)voidreleaseSavepoint(java.sql.Savepoint savepointParam)voidremoveNotificationListener(PGNotificationListener listener)Removes a notification listenervoidremoveNotificationListener(java.lang.String listenerName)Removes a named notification listenerPGAnyTyperesolveType(java.lang.String name)Resolves a name to an SQLType suitable for passing to any method that accepts one.voidrollback()voidrollback(java.sql.Savepoint savepointParam)voidsetAutoCommit(boolean autoCommit)voidsetCatalog(java.lang.String catalog)voidsetClientInfo(java.lang.String name, java.lang.String value)voidsetClientInfo(java.util.Properties properties)voidsetDefaultFetchSize(java.lang.Integer v)Set the default fetch sizevoidsetHoldability(int holdability)voidsetNetworkTimeout(java.util.concurrent.Executor executor, int networkTimeout)voidsetReadOnly(boolean readOnly)java.sql.SavepointsetSavepoint()java.sql.SavepointsetSavepoint(java.lang.String name)voidsetSchema(java.lang.String schema)voidsetStrictMode(boolean v)Set strict modevoidsetTransactionIsolation(int level)voidsetTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> typeMap)<T> Tunwrap(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:
initin 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:
setStrictModein interfacePGConnection- Parameters:
v- The value
-
isStrictMode
public boolean isStrictMode()
Is strict mode- Specified by:
isStrictModein interfacePGConnection- Returns:
- The value
-
setDefaultFetchSize
public void setDefaultFetchSize(java.lang.Integer v)
Set the default fetch size- Specified by:
setDefaultFetchSizein interfacePGConnection- Parameters:
v- The value
-
getDefaultFetchSize
public java.lang.Integer getDefaultFetchSize()
Get the default fetch size- Specified by:
getDefaultFetchSizein interfacePGConnection- Returns:
- The value
-
resolveType
public PGAnyType resolveType(java.lang.String name) throws java.sql.SQLException
Description copied from interface:PGConnectionResolves 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:
resolveTypein 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:BasicContextCalled whenBasicContext.serverConnectionwas closed externally (i.e. without callingBasicContext.shutdown()- Overrides:
connectionClosedin classBasicContext
-
isServerMinimumVersion
public boolean isServerMinimumVersion(int major, int minor)Checks the minimum server version- Specified by:
isServerMinimumVersionin interfacePGConnection- Parameters:
major- The major releaseminor- The minor release- Returns:
Trueif the server is minimum the specified version, otherwisefalse.
-
isValid
public boolean isValid(int timeout) throws java.sql.SQLException- Specified by:
isValidin 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:
getTypeMapin 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:
setTypeMapin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getHoldability
public int getHoldability() throws java.sql.SQLException- Specified by:
getHoldabilityin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setHoldability
public void setHoldability(int holdability) throws java.sql.SQLException- Specified by:
setHoldabilityin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getMetaData
public java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException- Specified by:
getMetaDatain interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getAutoCommit
public boolean getAutoCommit() throws java.sql.SQLException- Specified by:
getAutoCommitin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setAutoCommit
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException- Specified by:
setAutoCommitin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
isReadOnly
public boolean isReadOnly() throws java.sql.SQLException- Specified by:
isReadOnlyin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws java.sql.SQLException- Specified by:
setReadOnlyin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getTransactionIsolation
public int getTransactionIsolation() throws java.sql.SQLException- Specified by:
getTransactionIsolationin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws java.sql.SQLException- Specified by:
setTransactionIsolationin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
commit
public void commit() throws java.sql.SQLException- Specified by:
commitin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
rollback
public void rollback() throws java.sql.SQLException- Specified by:
rollbackin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException- Specified by:
setSavepointin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setSavepoint
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException- Specified by:
setSavepointin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
rollback
public void rollback(java.sql.Savepoint savepointParam) throws java.sql.SQLException- Specified by:
rollbackin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
releaseSavepoint
public void releaseSavepoint(java.sql.Savepoint savepointParam) throws java.sql.SQLException- Specified by:
releaseSavepointin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getCatalog
public java.lang.String getCatalog() throws java.sql.SQLException- Specified by:
getCatalogin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setCatalog
public void setCatalog(java.lang.String catalog) throws java.sql.SQLException- Specified by:
setCatalogin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getSchema
public java.lang.String getSchema() throws java.sql.SQLException- Specified by:
getSchemain interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setSchema
public void setSchema(java.lang.String schema) throws java.sql.SQLException- Specified by:
setSchemain interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
nativeSQL
public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLException- Specified by:
nativeSQLin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createStatement
public com.impossibl.postgres.jdbc.PGStatement createStatement() throws java.sql.SQLException- Specified by:
createStatementin 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:
createStatementin 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:
createStatementin 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:
prepareStatementin 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:
prepareStatementin 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:
prepareStatementin 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:
prepareStatementin 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:
prepareStatementin 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:
prepareStatementin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
prepareCall
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException- Specified by:
prepareCallin 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:
prepareCallin 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:
prepareCallin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createBlob
public java.sql.Blob createBlob() throws java.sql.SQLException- Specified by:
createBlobin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createClob
public java.sql.Clob createClob() throws java.sql.SQLException- Specified by:
createClobin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
createSQLXML
public java.sql.SQLXML createSQLXML() throws java.sql.SQLException- Specified by:
createSQLXMLin 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:
createArrayOfin 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:
createStructin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getClientInfo
public java.lang.String getClientInfo(java.lang.String name) throws java.sql.SQLException- Specified by:
getClientInfoin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getClientInfo
public java.util.Properties getClientInfo() throws java.sql.SQLException- Specified by:
getClientInfoin 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:
setClientInfoin interfacejava.sql.Connection- Throws:
java.sql.SQLClientInfoException
-
setClientInfo
public void setClientInfo(java.util.Properties properties) throws java.sql.SQLClientInfoException- Specified by:
setClientInfoin interfacejava.sql.Connection- Throws:
java.sql.SQLClientInfoException
-
createNClob
public java.sql.NClob createNClob() throws java.sql.SQLException- Specified by:
createNClobin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
isClosed
public boolean isClosed()
- Specified by:
isClosedin interfacejava.sql.Connection
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.sql.Connection
-
abort
public void abort(java.util.concurrent.Executor executor)
- Specified by:
abortin interfacejava.sql.Connection
-
getWarnings
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException- Specified by:
getWarningsin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
clearWarnings
public void clearWarnings() throws java.sql.SQLException- Specified by:
clearWarningsin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws java.sql.SQLException- Specified by:
getNetworkTimeoutin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
setNetworkTimeout
public void setNetworkTimeout(java.util.concurrent.Executor executor, int networkTimeout) throws java.sql.SQLException- Specified by:
setNetworkTimeoutin interfacejava.sql.Connection- Throws:
java.sql.SQLException
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
unwrapin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface)
- Specified by:
isWrapperForin interfacejava.sql.Wrapper
-
connectionNotificationReceived
protected void connectionNotificationReceived(int processId, java.lang.String channelName, java.lang.String payload)Description copied from class:BasicContextCalled whenBasicContext.serverConnectionreceived an asynchronous notification- Overrides:
connectionNotificationReceivedin classBasicContext
-
addNotificationListener
public void addNotificationListener(PGNotificationListener listener)
Description copied from interface:PGConnectionAdds an, unnamed, unfiltered, asynchronous notification listener to this connection- Specified by:
addNotificationListenerin interfacePGConnection- Parameters:
listener- Notification listener
-
addNotificationListener
public void addNotificationListener(java.lang.String channelNameFilter, PGNotificationListener listener)Description copied from interface:PGConnectionAdds an, unnamed, filtered, asynchronous notification listener to this connection- Specified by:
addNotificationListenerin 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:PGConnectionAdds a filtered asynchronous notification listener to this connection- Specified by:
addNotificationListenerin 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:PGConnectionRemoves a notification listener- Specified by:
removeNotificationListenerin interfacePGConnection- Parameters:
listener- Listener instance to remove
-
removeNotificationListener
public void removeNotificationListener(java.lang.String listenerName)
Description copied from interface:PGConnectionRemoves a named notification listener- Specified by:
removeNotificationListenerin interfacePGConnection- Parameters:
listenerName- Name of listener to remove
-
-