com.pivotal.gemfirexd.internal.jdbc

## Class ClientBaseDataSource

- java.lang.Object
- - com.pivotal.gemfirexd.internal.jdbc.ClientBaseDataSource

All Implemented Interfaces:
  Serializable, Referenceable

Direct Known Subclasses:
  ClientDataSource

    public abstract class ClientBaseDataSource
    extends Object
    implements Serializable, Referenceable

Base class for client-side DataSource implementations.

See Also:
  Serialized Form

### Field Summary

Fields
`static short` `CLEAR_TEXT_PASSWORD_SECURITY`
`protected String` `connectionAttributes`
`static short` `ENCRYPTED_PASSWORD_SECURITY`
`static short` `ENCRYPTED_USER_AND_PASSWORD_SECURITY`
`static int` `propertyDefault_portNumber`
`static boolean` `propertyDefault_retrieveMessageText`
`static short` `propertyDefault_securityMechanism`
`static String` `propertyDefault_serverName`
`static boolean` `propertyDefault_traceFileAppend`
`static int` `propertyDefault_traceLevel`
`static String` `propertyDefault_user`
`protected short` `securityMechanism`
`static int` `SSL_BASIC`
`static int` `SSL_OFF`
`static int` `SSL_PEER_AUTHENTICATION`
`static short` `STRONG_PASSWORD_SUBSTITUTE_SECURITY`
`static int` `TRACE_ALL`
`static int` `TRACE_CONNECTION_CALLS`
`static int` `TRACE_CONNECTS`
`static int` `TRACE_DIAGNOSTICS`
`static int` `TRACE_DRIVER_CONFIGURATION`
`static int` `TRACE_NONE`
`static int` `TRACE_PARAMETER_META_DATA`
`static int` `TRACE_PROTOCOL_FLOWS`
`static int` `TRACE_RESULT_SET_CALLS`
`static int` `TRACE_RESULT_SET_META_DATA`
`static int` `TRACE_STATEMENT_CALLS`
`static int` `TRACE_XA_CALLS`
`protected int` `traceLevel`
`static short` `USER_ONLY_SECURITY` The source security mechanism to use when connecting to this data source.

### Method Summary

Methods
`static LogWriter` `computeDncLogWriter(Connection connection, PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, String logWriterInUseSuffix, int traceFileSuffixIndex, int traceLevel)`
`static LogWriter` `computeDncLogWriterForNewConnection(PrintWriter logWriter, String traceDirectory, String traceFile, boolean traceFileAppend, int traceLevel, String logWriterInUseSuffix, int traceFileSuffixIndex)`
`static int` `getClientSSLMode(Properties properties)`
`String` `getConnectionAttributes()`
`String` `getCreateDatabase()`
`String` `getDatabaseName()`
`String` `getDataSourceName()`
`String` `getDescription()`
`static boolean` `getIsODBCDriver(Properties properties)`
`int` `getLoginTimeout()`
`PrintWriter` `getLogWriter()`
`String` `getPassword()`
`static String` `getPassword(Properties properties)`
`int` `getPortNumber()`
`Reference` `getReference()`
`boolean` `getRetrieveMessageText()`
`static boolean` `getRetrieveMessageText(Properties properties)`
`short` `getSecurityMechanism()` Return the security mechanism.
`static short` `getSecurityMechanism(Properties properties)` Return security mechanism if it is set, else upgrade the security mechanism if possible and return the upgraded security mechanism
`short` `getSecurityMechanism(String password)` Return the security mechanism for this datasource object.
`String` `getServerName()`
`String` `getShutdownDatabase()`
`String` `getSsl()`
`static int` `getSSLModeFromString(String s)`
`String` `getTraceDirectory()`
`static String` `getTraceDirectory(Properties properties)` Check if gemfirexd.client.traceDirectory is provided as a JVM property.
`String` `getTraceFile()`
`static String` `getTraceFile(Properties properties)`
`boolean` `getTraceFileAppend()`
`static boolean` `getTraceFileAppend(Properties properties)`
`int` `getTraceLevel()`
`static int` `getTraceLevel(Properties properties)` Check if gemfirexd.client.traceLevel is provided as a JVM property.
`static short` `getUpgradedSecurityMechanism(String password)` This method has logic to upgrade security mechanism to a better (more secure) one if it is possible.
`String` `getUser()`
`static String` `getUser(Properties properties)`
`int` `maxStatementsToPool()` Returns the maximum number of JDBC prepared statements a connection is allowed to cache.
`static String` `readSystemProperty(String key)` Read the value of the passed system property.
`void` `setConnectionAttributes(String prop)` Set this property to pass in more Derby specific connection URL attributes.
`void` `setCreateDatabase(String create)` Set this property to create a new database.
`void` `setDatabaseName(String databaseName)`
`void` `setDataSourceName(String dataSourceName)`
`void` `setDescription(String description)`
`void` `setLoginTimeout(int seconds)`
`void` `setLogWriter(PrintWriter logWriter)`
`static void` `setPassword(Properties properties, String password)`
`void` `setPassword(String password)`
`void` `setPortNumber(int portNumber)`
`void` `setRetrieveMessageText(boolean retrieveMessageText)`
`static void` `setSecurityMechanism(Properties properties, int secmec)`
`void` `setSecurityMechanism(short securityMechanism)` Sets the security mechanism.
`void` `setServerName(String serverName)`
`void` `setShutdownDatabase(String shutdown)` Set this property if one wishes to shutdown the database identified by databaseName.
`void` `setSsl(int mode)`
`void` `setSsl(String mode)`
`void` `setTraceDirectory(String traceDirectory)`
`void` `setTraceFile(String traceFile)`
`void` `setTraceFileAppend(boolean traceFileAppend)`
`void` `setTraceLevel(int traceLevel)`
`void` `setUser(String user)`
`static Properties` `tokenizeAttributes(String attributeString, Properties properties)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### propertyDefault_portNumber

    public static final int propertyDefault_portNumber

See Also:
  Constant Field Values

#### propertyDefault_serverName

    public static final String propertyDefault_serverName

See Also:
  Constant Field Values

#### SSL_OFF

    public static final int SSL_OFF

See Also:
  Constant Field Values

#### SSL_BASIC

    public static final int SSL_BASIC

See Also:
  Constant Field Values

#### SSL_PEER_AUTHENTICATION

    public static final int SSL_PEER_AUTHENTICATION

See Also:
  Constant Field Values

#### propertyDefault_user

    public static final String propertyDefault_user

See Also:
  Constant Field Values

#### securityMechanism

    protected short securityMechanism

#### propertyDefault_securityMechanism

    public static final short propertyDefault_securityMechanism

See Also:
  Constant Field Values

#### propertyDefault_retrieveMessageText

    public static final boolean propertyDefault_retrieveMessageText

See Also:
  Constant Field Values

#### propertyDefault_traceFileAppend

    public static final boolean propertyDefault_traceFileAppend

See Also:
  Constant Field Values

#### USER_ONLY_SECURITY

    public static final short USER_ONLY_SECURITY

The source security mechanism to use when connecting to this data source.

Security mechanism options are:

- USER_ONLY_SECURITY
- CLEAR_TEXT_PASSWORD_SECURITY
- ENCRYPTED_PASSWORD_SECURITY
- ENCRYPTED_USER_AND_PASSWORD_SECURITY - both password and user are encrypted
- STRONG_PASSWORD_SUBSTITUTE_SECURITY

The default security mechanism is USER_ONLY SECURITY

If the application specifies a security mechanism then it will be the only one attempted. If the specified security mechanism is not supported by the conversation then an exception will be thrown and there will be no additional retries.

This property is currently only available for the DNC driver.

Both user and password need to be set for all security mechanism except USER_ONLY_SECURITY

See Also:
  Constant Field Values

#### CLEAR_TEXT_PASSWORD_SECURITY

    public static final short CLEAR_TEXT_PASSWORD_SECURITY

See Also:
  Constant Field Values

#### ENCRYPTED_PASSWORD_SECURITY

    public static final short ENCRYPTED_PASSWORD_SECURITY

See Also:
  Constant Field Values

#### ENCRYPTED_USER_AND_PASSWORD_SECURITY

    public static final short ENCRYPTED_USER_AND_PASSWORD_SECURITY

See Also:
  Constant Field Values

#### STRONG_PASSWORD_SUBSTITUTE_SECURITY

    public static final short STRONG_PASSWORD_SUBSTITUTE_SECURITY

See Also:
  Constant Field Values

#### connectionAttributes

    protected String connectionAttributes

#### TRACE_NONE

    public static final int TRACE_NONE

See Also:
  Constant Field Values

#### TRACE_CONNECTION_CALLS

    public static final int TRACE_CONNECTION_CALLS

See Also:
  Constant Field Values

#### TRACE_STATEMENT_CALLS

    public static final int TRACE_STATEMENT_CALLS

See Also:
  Constant Field Values

#### TRACE_RESULT_SET_CALLS

    public static final int TRACE_RESULT_SET_CALLS

See Also:
  Constant Field Values

#### TRACE_DRIVER_CONFIGURATION

    public static final int TRACE_DRIVER_CONFIGURATION

See Also:
  Constant Field Values

#### TRACE_CONNECTS

    public static final int TRACE_CONNECTS

See Also:
  Constant Field Values

#### TRACE_PROTOCOL_FLOWS

    public static final int TRACE_PROTOCOL_FLOWS

See Also:
  Constant Field Values

#### TRACE_RESULT_SET_META_DATA

    public static final int TRACE_RESULT_SET_META_DATA

See Also:
  Constant Field Values

#### TRACE_PARAMETER_META_DATA

    public static final int TRACE_PARAMETER_META_DATA

See Also:
  Constant Field Values

#### TRACE_DIAGNOSTICS

    public static final int TRACE_DIAGNOSTICS

See Also:
  Constant Field Values

#### TRACE_XA_CALLS

    public static final int TRACE_XA_CALLS

See Also:
  Constant Field Values

#### TRACE_ALL

    public static final int TRACE_ALL

See Also:
  Constant Field Values

#### propertyDefault_traceLevel

    public static final int propertyDefault_traceLevel

See Also:
  Constant Field Values

#### traceLevel

    protected int traceLevel

### Method Detail

#### setLoginTimeout

    public void setLoginTimeout(int seconds)

#### getLoginTimeout

    public int getLoginTimeout()

#### setLogWriter

    public void setLogWriter(PrintWriter logWriter)

#### getLogWriter

    public PrintWriter getLogWriter()

#### getSSLModeFromString

    public static final int getSSLModeFromString(String s)
                                          throws SqlException

Throws:
  `SqlException`

#### getClientSSLMode

    public static final int getClientSSLMode(Properties properties)
                                      throws SqlException

Throws:
  `SqlException`

#### getUser

    public static String getUser(Properties properties)

#### getSecurityMechanism

    public static short getSecurityMechanism(Properties properties)

Return security mechanism if it is set, else upgrade the security mechanism if possible and return the upgraded security mechanism

Parameters:
  `properties` - Look in the properties if securityMechanism is set or not if set, return this security mechanism
Returns:
  security mechanism

#### setSecurityMechanism

    public static void setSecurityMechanism(Properties properties,
                            int secmec)

#### getUpgradedSecurityMechanism

    public static short getUpgradedSecurityMechanism(String password)

This method has logic to upgrade security mechanism to a better (more secure) one if it is possible. Currently derby server only has support for USRIDPWD, USRIDONL, EUSRIDPWD and USRSSBPWD (10.2+) - this method only considers these possibilities. USRIDPWD, EUSRIDPWD and USRSSBPWD require a password, USRIDONL is the only security mechanism which does not require password. 1. if password is not available, then security mechanism possible is USRIDONL 2. if password is available,then USRIDPWD is returned.

Parameters:
  `password` - password argument
Returns:
  upgraded security mechanism if possible

#### getRetrieveMessageText

    public static boolean getRetrieveMessageText(Properties properties)

#### getTraceFile

    public static String getTraceFile(Properties properties)

#### getTraceDirectory

    public static String getTraceDirectory(Properties properties)

Check if gemfirexd.client.traceDirectory is provided as a JVM property. If yes, then we use that value. If not, then we look for traceDirectory in the the properties parameter.

Parameters:
  `properties` - jdbc url properties
Returns:
  value of traceDirectory property

#### readSystemProperty

    public static String readSystemProperty(String key)

Read the value of the passed system property.

Parameters:
  `key` - name of the system property
Returns:
  value of the system property, null if there is no permission to read the property

#### getTraceFileAppend

    public static boolean getTraceFileAppend(Properties properties)

#### getPassword

    public static String getPassword(Properties properties)

#### setPassword

    public static void setPassword(Properties properties,
                   String password)

#### getIsODBCDriver

    public static boolean getIsODBCDriver(Properties properties)

#### setPassword

    public final void setPassword(String password)

#### getPassword

    public final String getPassword()

#### getReference

    public Reference getReference()
                           throws NamingException

Specified by:
  `getReference` in interface `Referenceable`
Throws:
  `NamingException`

#### computeDncLogWriterForNewConnection

    public static LogWriter computeDncLogWriterForNewConnection(PrintWriter logWriter,
                                                String traceDirectory,
                                                String traceFile,
                                                boolean traceFileAppend,
                                                int traceLevel,
                                                String logWriterInUseSuffix,
                                                int traceFileSuffixIndex)
                                                         throws SqlException

Throws:
  `SqlException`

#### computeDncLogWriter

    public static LogWriter computeDncLogWriter(Connection connection,
                                PrintWriter logWriter,
                                String traceDirectory,
                                String traceFile,
                                boolean traceFileAppend,
                                String logWriterInUseSuffix,
                                int traceFileSuffixIndex,
                                int traceLevel)
                                         throws SqlException

Throws:
  `SqlException`

#### tokenizeAttributes

    public static Properties tokenizeAttributes(String attributeString,
                                Properties properties)
                                         throws SqlException

Throws:
  `SqlException`

#### setDatabaseName

    public void setDatabaseName(String databaseName)

#### getDatabaseName

    public String getDatabaseName()

#### setDataSourceName

    public void setDataSourceName(String dataSourceName)

#### getDataSourceName

    public String getDataSourceName()

#### setDescription

    public void setDescription(String description)

#### getDescription

    public String getDescription()

#### setPortNumber

    public void setPortNumber(int portNumber)

#### getPortNumber

    public int getPortNumber()

#### setServerName

    public void setServerName(String serverName)

#### getServerName

    public String getServerName()

#### setUser

    public void setUser(String user)

#### getUser

    public String getUser()

#### setRetrieveMessageText

    public void setRetrieveMessageText(boolean retrieveMessageText)

#### getRetrieveMessageText

    public boolean getRetrieveMessageText()

#### setSecurityMechanism

    public void setSecurityMechanism(short securityMechanism)

Sets the security mechanism.

Parameters:
  `securityMechanism` - to set

#### getSecurityMechanism

    public short getSecurityMechanism()

Return the security mechanism. If security mechanism has not been set explicitly on datasource, then upgrade the security mechanism to a more secure one if possible.

Returns:
  the security mechanism
See Also:
  `getUpgradedSecurityMechanism(String)`

#### getSecurityMechanism

    public short getSecurityMechanism(String password)

Return the security mechanism for this datasource object. If security mechanism has not been set explicitly on datasource, then upgrade the security mechanism to a more secure one if possible.

Parameters:
  `password` - password of user
Returns:
  the security mechanism
See Also:
  `getUpgradedSecurityMechanism(String)`

#### setSsl

    public void setSsl(String mode)
                throws SqlException

Throws:
  `SqlException`

#### setSsl

    public void setSsl(int mode)

#### getSsl

    public String getSsl()

#### setCreateDatabase

    public final void setCreateDatabase(String create)

Set this property to create a new database. If this property is not set, the database (identified by databaseName) is assumed to be already existing.

Parameters:
  `create` - if set to the string "create", this data source will try to create a new database of databaseName, or boot the database if one by that name already exists.

#### getCreateDatabase

    public final String getCreateDatabase()

Returns:
  "create" if create is set, or null if not

#### setShutdownDatabase

    public final void setShutdownDatabase(String shutdown)

Set this property if one wishes to shutdown the database identified by databaseName.

Parameters:
  `shutdown` - if set to the string "shutdown", this data source will shutdown the database if it is running.

#### getShutdownDatabase

    public final String getShutdownDatabase()

Returns:
  "shutdown" if shutdown is set, or null if not

#### setConnectionAttributes

    public final void setConnectionAttributes(String prop)

Set this property to pass in more Derby specific connection URL attributes.
Any attributes that can be set using a property of this DataSource implementation (e.g user, password) should not be set in connectionAttributes. Conflicting settings in connectionAttributes and properties of the DataSource will lead to unexpected behaviour.

Parameters:
  `prop` - set to the list of Derby connection attributes separated by semi-colons. E.g., to specify an encryption bootPassword of "x8hhk2adf", and set upgrade to true, do the following:

                   ds.setConnectionAttributes("bootPassword=x8hhk2adf;upgrade=true");

  See Derby documentation for complete list.

#### getConnectionAttributes

    public final String getConnectionAttributes()

Returns:
  Derby specific connection URL attributes

#### getTraceLevel

    public static int getTraceLevel(Properties properties)

Check if gemfirexd.client.traceLevel is provided as a JVM property. If yes, then we use that value. If not, then we look for traceLevel in the the properties parameter.

Parameters:
  `properties` - jdbc url properties
Returns:
  value of traceLevel property

#### setTraceLevel

    public void setTraceLevel(int traceLevel)

#### getTraceLevel

    public int getTraceLevel()

#### setTraceFile

    public void setTraceFile(String traceFile)

#### getTraceFile

    public String getTraceFile()

#### setTraceDirectory

    public void setTraceDirectory(String traceDirectory)

#### getTraceDirectory

    public String getTraceDirectory()

#### setTraceFileAppend

    public void setTraceFileAppend(boolean traceFileAppend)

#### getTraceFileAppend

    public boolean getTraceFileAppend()

#### maxStatementsToPool

    public int maxStatementsToPool()

Returns the maximum number of JDBC prepared statements a connection is allowed to cache.

A basic data source will always return zero. If statement caching is required, use a `ConnectionPoolDataSource`.

This method is used internally by Derby to determine if statement pooling is to be enabled or not.

Returns:
  Maximum number of statements to cache, or `0` if caching is disabled (default).
See Also:
  `ClientConnectionPoolDataSource`