public abstract class BaseDataSource extends Object implements CommonDataSource, Referenceable
Constructor and Description |
---|
BaseDataSource() |
Modifier and Type | Method and Description |
---|---|
protected Reference |
createReference()
Generates a reference using the appropriate object factory.
|
boolean |
getAllowEncodingChanges() |
String |
getApplicationName() |
String |
getAssumeMinServerVersion() |
AutoSave |
getAutosave() |
boolean |
getBinaryTransfer() |
String |
getBinaryTransferDisable() |
String |
getBinaryTransferEnable() |
int |
getCancelSignalTimeout() |
Connection |
getConnection()
Gets a connection to the PostgreSQL database.
|
Connection |
getConnection(String user,
String password)
Gets a connection to the PostgreSQL database.
|
int |
getConnectTimeout() |
String |
getCurrentSchema() |
int |
getDatabaseMetadataCacheFields() |
int |
getDatabaseMetadataCacheFieldsMiB() |
String |
getDatabaseName()
Gets the name of the PostgreSQL database, running on the server identified by the serverName
property.
|
int |
getDefaultRowFetchSize() |
abstract String |
getDescription()
Gets a description of this DataSource-ish thing.
|
boolean |
getDisableColumnSanitiser() |
String |
getGssLib() |
int |
getHostRecheckSeconds() |
String |
getJaasApplicationName() |
boolean |
getJaasLogin() |
String |
getKerberosServerName() |
boolean |
getLoadBalanceHosts() |
String |
getLoggerFile() |
String |
getLoggerLevel() |
int |
getLoginTimeout()
Gets the maximum time in seconds that this data source can wait
while attempting to connect to a database.
|
boolean |
getLogUnclosedConnections() |
PrintWriter |
getLogWriter()
This implementation don't use a LogWriter.
|
Logger |
getParentLogger()
Return the parent Logger of all the Loggers used by this data source.
|
String |
getPassword()
Gets the password to connect with by default.
|
int |
getPortNumber()
Gets the port which the PostgreSQL server is listening on for TCP/IP connections.
|
PreferQueryMode |
getPreferQueryMode() |
int |
getPreparedStatementCacheQueries() |
int |
getPreparedStatementCacheSizeMiB() |
int |
getPrepareThreshold() |
String |
getProperty(PGProperty property) |
String |
getProperty(String name) |
int |
getProtocolVersion() |
boolean |
getReadOnly() |
int |
getReceiveBufferSize() |
Reference |
getReference()
Retrieves the Reference of this object.
|
String |
getReplication() |
boolean |
getReWriteBatchedInserts() |
int |
getSendBufferSize() |
String |
getServerName()
Gets the name of the host the PostgreSQL database is running on.
|
String |
getSocketFactory() |
String |
getSocketFactoryArg() |
int |
getSocketTimeout() |
boolean |
getSsl() |
String |
getSslCert() |
String |
getSslfactory() |
String |
getSslFactoryArg() |
String |
getSslHostnameVerifier() |
String |
getSslKey() |
String |
getSslMode() |
String |
getSslPassword() |
String |
getSslPasswordCallback() |
String |
getSslRootCert() |
String |
getSspiServiceClass() |
String |
getStringType() |
String |
getTargetServerType() |
boolean |
getTcpKeepAlive() |
int |
getUnknownLength() |
String |
getUrl()
Generates a
DriverManager URL from the other properties supplied. |
String |
getURL()
Generates a
DriverManager URL from the other properties supplied. |
String |
getUser()
Gets the user to connect as by default.
|
boolean |
getUseSpNego() |
void |
initializeFrom(BaseDataSource source) |
boolean |
isColumnSanitiserDisabled() |
protected void |
readBaseObject(ObjectInputStream in) |
void |
setAllowEncodingChanges(boolean allow) |
void |
setApplicationName(String applicationName) |
void |
setAssumeMinServerVersion(String minVersion) |
void |
setAutosave(AutoSave autoSave) |
void |
setBinaryTransfer(boolean enabled) |
void |
setBinaryTransferDisable(String oidList) |
void |
setBinaryTransferEnable(String oidList) |
void |
setCancelSignalTimeout(int seconds) |
void |
setConnectTimeout(int connectTimeout) |
void |
setCurrentSchema(String currentSchema) |
void |
setDatabaseMetadataCacheFields(int cacheSize) |
void |
setDatabaseMetadataCacheFieldsMiB(int cacheSize) |
void |
setDatabaseName(String databaseName)
Sets the name of the PostgreSQL database, running on the server identified by the serverName
property.
|
void |
setDefaultRowFetchSize(int fetchSize) |
void |
setDisableColumnSanitiser(boolean disableColumnSanitiser) |
void |
setFromReference(Reference ref) |
void |
setGssLib(String lib) |
void |
setHostRecheckSeconds(int hostRecheckSeconds) |
void |
setJaasApplicationName(String name) |
void |
setJaasLogin(boolean doLogin) |
void |
setKerberosServerName(String serverName) |
void |
setLoadBalanceHosts(boolean loadBalanceHosts) |
void |
setLoggerFile(String loggerFile) |
void |
setLoggerLevel(String loggerLevel) |
void |
setLoginTimeout(int loginTimeout)
Sets the maximum time in seconds that this data source will wait
while attempting to connect to a database.
|
void |
setLogUnclosedConnections(boolean enabled) |
void |
setLogWriter(PrintWriter printWriter)
This implementation don't use a LogWriter.
|
void |
setPassword(String password)
Sets the password to connect with by default.
|
void |
setPortNumber(int portNumber)
Gets the port which the PostgreSQL server is listening on for TCP/IP connections.
|
void |
setPreferQueryMode(PreferQueryMode preferQueryMode) |
void |
setPreparedStatementCacheQueries(int cacheSize) |
void |
setPreparedStatementCacheSizeMiB(int cacheSize) |
void |
setPrepareThreshold(int count) |
void |
setProperty(PGProperty property,
String value) |
void |
setProperty(String name,
String value) |
void |
setProtocolVersion(int protocolVersion) |
void |
setReadOnly(boolean readOnly) |
void |
setReceiveBufferSize(int nbytes) |
void |
setReplication(String replication) |
void |
setReWriteBatchedInserts(boolean reWrite) |
void |
setSendBufferSize(int nbytes) |
void |
setServerName(String serverName)
Sets the name of the host the PostgreSQL database is running on.
|
void |
setSocketFactory(String socketFactoryClassName) |
void |
setSocketFactoryArg(String socketFactoryArg) |
void |
setSocketTimeout(int seconds) |
void |
setSsl(boolean enabled) |
void |
setSslCert(String file) |
void |
setSslfactory(String classname) |
void |
setSslFactoryArg(String arg) |
void |
setSslHostnameVerifier(String className) |
void |
setSslKey(String file) |
void |
setSslMode(String mode) |
void |
setSslPassword(String password) |
void |
setSslPasswordCallback(String className) |
void |
setSslRootCert(String file) |
void |
setSspiServiceClass(String serviceClass) |
void |
setStringType(String stringType) |
void |
setTargetServerType(String targetServerType) |
void |
setTcpKeepAlive(boolean enabled) |
void |
setUnknownLength(int unknownLength) |
void |
setUrl(String url)
Sets properties from a
DriverManager URL. |
void |
setURL(String url)
Sets properties from a
DriverManager URL. |
void |
setUser(String user)
Sets the user to connect as by default.
|
void |
setUseSpNego(boolean use) |
protected void |
writeBaseObject(ObjectOutputStream out) |
public Connection getConnection() throws SQLException
SQLException
- Occurs when the database connection cannot be established.public Connection getConnection(String user, String password) throws SQLException
user
- userpassword
- passwordSQLException
- Occurs when the database connection cannot be established.public PrintWriter getLogWriter()
getLogWriter
in interface CommonDataSource
CommonDataSource.setLogWriter(java.io.PrintWriter)
public void setLogWriter(PrintWriter printWriter)
setLogWriter
in interface CommonDataSource
printWriter
- Not usedCommonDataSource.getLogWriter()
public String getServerName()
public void setServerName(String serverName)
serverName
- name of the host the PostgreSQL database is running onpublic String getDatabaseName()
public void setDatabaseName(String databaseName)
databaseName
- name of the PostgreSQL databasepublic abstract String getDescription()
public String getUser()
public void setUser(String user)
user
- user to connect as by defaultpublic String getPassword()
public void setPassword(String password)
password
- password to connect with by defaultpublic int getPortNumber()
public void setPortNumber(int portNumber)
portNumber
- port which the PostgreSQL server is listening on for TCP/IPpublic int getLoginTimeout()
javax.sql.CommonDataSource
DataSource
object is created, the login timeout is
initially zero.getLoginTimeout
in interface CommonDataSource
PGProperty.LOGIN_TIMEOUT
public void setLoginTimeout(int loginTimeout)
javax.sql.CommonDataSource
Sets the maximum time in seconds that this data source will wait
while attempting to connect to a database. A value of zero
specifies that the timeout is the default system timeout
if there is one; otherwise, it specifies that there is no timeout.
When a DataSource
object is created, the login timeout is
initially zero.
setLoginTimeout
in interface CommonDataSource
loginTimeout
- login timeoutPGProperty.LOGIN_TIMEOUT
public int getConnectTimeout()
PGProperty.CONNECT_TIMEOUT
public void setConnectTimeout(int connectTimeout)
connectTimeout
- connect timeoutPGProperty.CONNECT_TIMEOUT
public int getProtocolVersion()
PGProperty.PROTOCOL_VERSION
public void setProtocolVersion(int protocolVersion)
protocolVersion
- protocol versionPGProperty.PROTOCOL_VERSION
public int getReceiveBufferSize()
PGProperty.RECEIVE_BUFFER_SIZE
public void setReceiveBufferSize(int nbytes)
nbytes
- receive buffer sizePGProperty.RECEIVE_BUFFER_SIZE
public int getSendBufferSize()
PGProperty.SEND_BUFFER_SIZE
public void setSendBufferSize(int nbytes)
nbytes
- send buffer sizePGProperty.SEND_BUFFER_SIZE
public void setPrepareThreshold(int count)
count
- prepare thresholdPGProperty.PREPARE_THRESHOLD
public int getPrepareThreshold()
PGProperty.PREPARE_THRESHOLD
public int getPreparedStatementCacheQueries()
PGProperty.PREPARED_STATEMENT_CACHE_QUERIES
public void setPreparedStatementCacheQueries(int cacheSize)
cacheSize
- prepared statement cache size (number of statements per connection)PGProperty.PREPARED_STATEMENT_CACHE_QUERIES
public int getPreparedStatementCacheSizeMiB()
PGProperty.PREPARED_STATEMENT_CACHE_SIZE_MIB
public void setPreparedStatementCacheSizeMiB(int cacheSize)
cacheSize
- statement cache size (number of megabytes per connection)PGProperty.PREPARED_STATEMENT_CACHE_SIZE_MIB
public int getDatabaseMetadataCacheFields()
PGProperty.DATABASE_METADATA_CACHE_FIELDS
public void setDatabaseMetadataCacheFields(int cacheSize)
cacheSize
- database metadata cache fields size (number of fields cached per connection)PGProperty.DATABASE_METADATA_CACHE_FIELDS
public int getDatabaseMetadataCacheFieldsMiB()
PGProperty.DATABASE_METADATA_CACHE_FIELDS_MIB
public void setDatabaseMetadataCacheFieldsMiB(int cacheSize)
cacheSize
- database metadata cache fields size (number of megabytes per connection)PGProperty.DATABASE_METADATA_CACHE_FIELDS_MIB
public void setDefaultRowFetchSize(int fetchSize)
fetchSize
- default fetch sizePGProperty.DEFAULT_ROW_FETCH_SIZE
public int getDefaultRowFetchSize()
PGProperty.DEFAULT_ROW_FETCH_SIZE
public void setUnknownLength(int unknownLength)
unknownLength
- unknown lengthPGProperty.UNKNOWN_LENGTH
public int getUnknownLength()
PGProperty.UNKNOWN_LENGTH
public void setSocketTimeout(int seconds)
seconds
- socket timeoutPGProperty.SOCKET_TIMEOUT
public int getSocketTimeout()
PGProperty.SOCKET_TIMEOUT
public void setCancelSignalTimeout(int seconds)
seconds
- timeout that is used for sending cancel commandPGProperty.CANCEL_SIGNAL_TIMEOUT
public int getCancelSignalTimeout()
PGProperty.CANCEL_SIGNAL_TIMEOUT
public void setSsl(boolean enabled)
enabled
- if SSL is enabledPGProperty.SSL
public boolean getSsl()
PGProperty.SSL
public void setSslfactory(String classname)
classname
- SSL factory class namePGProperty.SSL_FACTORY
public String getSslfactory()
PGProperty.SSL_FACTORY
public String getSslMode()
PGProperty.SSL_MODE
public void setSslMode(String mode)
mode
- SSL modePGProperty.SSL_MODE
public String getSslFactoryArg()
PGProperty.SSL_FACTORY_ARG
public void setSslFactoryArg(String arg)
arg
- argument forwarded to SSL factoryPGProperty.SSL_FACTORY_ARG
public String getSslHostnameVerifier()
PGProperty.SSL_HOSTNAME_VERIFIER
public void setSslHostnameVerifier(String className)
className
- SSL hostname verifierPGProperty.SSL_HOSTNAME_VERIFIER
public String getSslCert()
PGProperty.SSL_CERT
public void setSslCert(String file)
file
- SSL certificatePGProperty.SSL_CERT
public String getSslKey()
PGProperty.SSL_KEY
public void setSslKey(String file)
file
- SSL keyPGProperty.SSL_KEY
public String getSslRootCert()
PGProperty.SSL_ROOT_CERT
public void setSslRootCert(String file)
file
- SSL root certificatePGProperty.SSL_ROOT_CERT
public String getSslPassword()
PGProperty.SSL_PASSWORD
public void setSslPassword(String password)
password
- SSL passwordPGProperty.SSL_PASSWORD
public String getSslPasswordCallback()
PGProperty.SSL_PASSWORD_CALLBACK
public void setSslPasswordCallback(String className)
className
- SSL password callback class namePGProperty.SSL_PASSWORD_CALLBACK
public void setApplicationName(String applicationName)
applicationName
- application namePGProperty.APPLICATION_NAME
public String getApplicationName()
PGProperty.APPLICATION_NAME
public void setTargetServerType(String targetServerType)
targetServerType
- target server typePGProperty.TARGET_SERVER_TYPE
public String getTargetServerType()
PGProperty.TARGET_SERVER_TYPE
public void setLoadBalanceHosts(boolean loadBalanceHosts)
loadBalanceHosts
- load balance hostsPGProperty.LOAD_BALANCE_HOSTS
public boolean getLoadBalanceHosts()
PGProperty.LOAD_BALANCE_HOSTS
public void setHostRecheckSeconds(int hostRecheckSeconds)
hostRecheckSeconds
- host recheck secondsPGProperty.HOST_RECHECK_SECONDS
public int getHostRecheckSeconds()
PGProperty.HOST_RECHECK_SECONDS
public void setTcpKeepAlive(boolean enabled)
enabled
- if TCP keep alive should be enabledPGProperty.TCP_KEEP_ALIVE
public boolean getTcpKeepAlive()
PGProperty.TCP_KEEP_ALIVE
public void setBinaryTransfer(boolean enabled)
enabled
- if binary transfer should be enabledPGProperty.BINARY_TRANSFER
public boolean getBinaryTransfer()
PGProperty.BINARY_TRANSFER
public void setBinaryTransferEnable(String oidList)
oidList
- list of OIDs that are allowed to use binary transferPGProperty.BINARY_TRANSFER_ENABLE
public String getBinaryTransferEnable()
PGProperty.BINARY_TRANSFER_ENABLE
public void setBinaryTransferDisable(String oidList)
oidList
- list of OIDs that are not allowed to use binary transferPGProperty.BINARY_TRANSFER_DISABLE
public String getBinaryTransferDisable()
PGProperty.BINARY_TRANSFER_DISABLE
public String getStringType()
PGProperty.STRING_TYPE
public void setStringType(String stringType)
stringType
- string typePGProperty.STRING_TYPE
public boolean isColumnSanitiserDisabled()
PGProperty.DISABLE_COLUMN_SANITISER
public boolean getDisableColumnSanitiser()
PGProperty.DISABLE_COLUMN_SANITISER
public void setDisableColumnSanitiser(boolean disableColumnSanitiser)
disableColumnSanitiser
- if column sanitizer should be disabledPGProperty.DISABLE_COLUMN_SANITISER
public String getCurrentSchema()
PGProperty.CURRENT_SCHEMA
public void setCurrentSchema(String currentSchema)
currentSchema
- current schemaPGProperty.CURRENT_SCHEMA
public boolean getReadOnly()
PGProperty.READ_ONLY
public void setReadOnly(boolean readOnly)
readOnly
- if connection should be readonlyPGProperty.READ_ONLY
public boolean getLogUnclosedConnections()
PGProperty.LOG_UNCLOSED_CONNECTIONS
public void setLogUnclosedConnections(boolean enabled)
enabled
- true if driver should log unclosed connectionsPGProperty.LOG_UNCLOSED_CONNECTIONS
public String getAssumeMinServerVersion()
PGProperty.ASSUME_MIN_SERVER_VERSION
public void setAssumeMinServerVersion(String minVersion)
minVersion
- assumed minimal server versionPGProperty.ASSUME_MIN_SERVER_VERSION
public String getJaasApplicationName()
PGProperty.JAAS_APPLICATION_NAME
public void setJaasApplicationName(String name)
name
- JAAS application namePGProperty.JAAS_APPLICATION_NAME
public boolean getJaasLogin()
PGProperty.JAAS_LOGIN
public void setJaasLogin(boolean doLogin)
doLogin
- true if perform JAAS login before GSS authenticationPGProperty.JAAS_LOGIN
public String getKerberosServerName()
PGProperty.KERBEROS_SERVER_NAME
public void setKerberosServerName(String serverName)
serverName
- Kerberos server namePGProperty.KERBEROS_SERVER_NAME
public boolean getUseSpNego()
PGProperty.USE_SPNEGO
public void setUseSpNego(boolean use)
use
- true if use SPNEGOPGProperty.USE_SPNEGO
public String getGssLib()
PGProperty.GSS_LIB
public void setGssLib(String lib)
lib
- GSS mode: auto, sspi, or gssapiPGProperty.GSS_LIB
public String getSspiServiceClass()
PGProperty.SSPI_SERVICE_CLASS
public void setSspiServiceClass(String serviceClass)
serviceClass
- SSPI service classPGProperty.SSPI_SERVICE_CLASS
public boolean getAllowEncodingChanges()
PGProperty.ALLOW_ENCODING_CHANGES
public void setAllowEncodingChanges(boolean allow)
allow
- if connection allows encoding changesPGProperty.ALLOW_ENCODING_CHANGES
public String getSocketFactory()
PGProperty.SOCKET_FACTORY
public void setSocketFactory(String socketFactoryClassName)
socketFactoryClassName
- socket factory class namePGProperty.SOCKET_FACTORY
public String getSocketFactoryArg()
PGProperty.SOCKET_FACTORY_ARG
public void setSocketFactoryArg(String socketFactoryArg)
socketFactoryArg
- socket factory argumentPGProperty.SOCKET_FACTORY_ARG
public void setReplication(String replication)
replication
- set to 'database' for logical replication or 'true' for physical replicationPGProperty.REPLICATION
public String getReplication()
PGProperty.REPLICATION
public String getLoggerLevel()
PGProperty.LOGGER_LEVEL
public void setLoggerLevel(String loggerLevel)
loggerLevel
- of the JDBC DriverPGProperty.LOGGER_LEVEL
public String getLoggerFile()
PGProperty.LOGGER_FILE
public void setLoggerFile(String loggerFile)
loggerFile
- File output of the Logger.PGProperty.LOGGER_LEVEL
public String getUrl()
DriverManager
URL from the other properties supplied.DriverManager
URL from the other properties suppliedpublic String getURL()
DriverManager
URL from the other properties supplied.DriverManager
URL from the other properties suppliedpublic void setUrl(String url)
DriverManager
URL.url
- properties to setpublic void setURL(String url)
DriverManager
URL.
Added to follow convention used in other DBMS.url
- properties to setpublic String getProperty(String name) throws SQLException
SQLException
public void setProperty(String name, String value) throws SQLException
SQLException
public String getProperty(PGProperty property)
public void setProperty(PGProperty property, String value)
protected Reference createReference()
public Reference getReference() throws NamingException
javax.naming.Referenceable
getReference
in interface Referenceable
NamingException
- If a naming exception was encountered
while retrieving the reference.public void setFromReference(Reference ref)
protected void writeBaseObject(ObjectOutputStream out) throws IOException
IOException
protected void readBaseObject(ObjectInputStream in) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public void initializeFrom(BaseDataSource source) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public PreferQueryMode getPreferQueryMode()
PGProperty.PREFER_QUERY_MODE
public void setPreferQueryMode(PreferQueryMode preferQueryMode)
preferQueryMode
- extended, simple, extendedForPrepared, or extendedCacheEverythingPGProperty.PREFER_QUERY_MODE
public AutoSave getAutosave()
PGProperty.AUTOSAVE
public void setAutosave(AutoSave autoSave)
autoSave
- connection configuration regarding automatic per-query savepointsPGProperty.AUTOSAVE
public boolean getReWriteBatchedInserts()
PGProperty.REWRITE_BATCHED_INSERTS
public void setReWriteBatchedInserts(boolean reWrite)
reWrite
- boolean value to set the property in the properties collectionPGProperty.REWRITE_BATCHED_INSERTS
public Logger getParentLogger()
javax.sql.CommonDataSource
getParentLogger
in interface CommonDataSource
Copyright © 2018 PostgreSQL Global Development Group. All rights reserved.