com.intersystems.jdbc

## Class IRISDataSource

- java.lang.Object
- - com.intersystems.jdbc.IRISWrapper
  - - com.intersystems.jdbc.ConnectionParameters
    - - com.intersystems.jdbc.IRISDataSource

All Implemented Interfaces:
  Cloneable, Wrapper, CommonDataSource, DataSource

Direct Known Subclasses:
  IRISConnectionPoolDataSource

    public class IRISDataSource
    extends com.intersystems.jdbc.ConnectionParameters
    implements DataSource

`IRISDataSource` is an implementation of the `java.sql.DataSource` interface. `IRISDataSource` also includes a number of InterSystems IRIS specific extensions that can be used to set up the `DataSource`.

By default, `IRISDataSource` will attempt to connect to "127.0.0.1:1972/USER". Username and Password can be set via the setters, or alternatively, can be supplied via the `getConnection(String usr, String pwd)`.

### Field Summary

Fields
`protected com.intersystems.jdbc.LogFileStream` `logFile`

### Fields inherited from class com.intersystems.jdbc.ConnectionParameters

`autobalance, isolationLevel, isPiped, keyRecoveryPassword, principalName, sqlDialect, sSLConfigName`

### Constructor Summary

Constructors
Constructor and Description
`IRISDataSource()`

### Method Summary

All Methods Instance Methods Concrete Methods
`String` `getAccessToken()` Returns a `String` representing the current AccessToken.
`Connection` `getConnection()`
`Connection` `getConnection(String usr, String pwd)`
`int` `getConnectionSecurityLevel()` Returns an `int` representing current Connection Security Level setting.
`String` `getDatabaseName()` Returns a `String` representing the current database (InterSystems IRIS Namespace) name.
`String` `getDataSourceName()` Returns a `String` representing the current Data Source Name.
`int` `getDefaultTransactionIsolation()` Returns an `int` representing current Default Transaction Isolation Level.
`String` `getDescription()` Returns a `String` representing the current description.
`String` `getEventClass()` Returns a `String` representing the Event Class object.
`int` `getFeatureOption()` Returns an `int` representing the current Feature Option setting.
`String` `getKeyRecoveryPassword()` Returns a `String` representing current Key Recovery Password.
`com.intersystems.jdbc.LogFileStream` `getLogFile()` Returns a `LogFileStream` as the current log file instance.
`String` `getLogFileName()` Returns a `String` representing the current log file path.
`int` `getLoginTimeout()` Gets the time, in seconds, that the driver will wait for to obtain a connection before throwing a SQLException.
`PrintWriter` `getLogWriter()` Returns a `PrintWriter` as the current log file instance.
`boolean` `getNodelay()` Returns a `boolean` representing the current TCP_NODELAY flag setting.
`Logger` `getParentLogger()`
`String` `getPassword()` Returns a `String` representing the current password.
`int` `getPortNumber()` Returns an `int` representing the current port number.
`int` `getPreparseCacheSize()` Returns an `int` representing the Preparsed Cache size.
`String` `getServerName()` Returns a `String` representing the current host.
`String` `getServicePrincipalName()` Returns a `String` representing current Service Principal Name.
`Boolean` `getSharedMemory()` Returns an `boolean` representing whether or not shared memory connections are enabled for this `DataSource` object.
`String` `getSSLConfigurationName()` Returns a `String` representing current SSL Configuration Name.
`int` `getStreamPrefetchSize()` Returns an `int` representing the Stream Prefetch size.
`String` `getURL()` Returns a `String` representing a current URL for this `DataSource` object.
`String` `getUser()` Returns a `String` representing the current username.
`void` `setAccessToken(String token)` Sets the AccessToken for this `DataSource` object.
`void` `setCommitTimeout(int timeout)` Sets the commitTimeout for this `DataSource` object.
`void` `setConnectionSecurityLevel(int level)` Sets the Connection Security Level for this `DataSource` object.
`void` `setDatabaseName(String databaseName)` Sets Database (InterSystems IRIS Namespace) name for this `DataSource` object.
`void` `setDataSourceName(String dataSourceName)` Sets tthe Data Source Name for this `DataSource` object.
`void` `setDefaultTransactionIsolation(int level)` Sets the default Transaction Isolation Level for this `DataSource` object.
`void` `setDescription(String desc)` Sets the description for this `DataSource` object.
`void` `setEventClass(String eventClassName)` Sets the Event Class for this `DataSource` object.
`void` `setFeatureOption(int feature)` Sets the current Feature Option setting.
`void` `setFeatureOption(String sfeature)` Sets the current Feature Option setting.
`void` `setKeyRecoveryPassword(String password)` Sets the Key Recovery Password for this `DataSource` object.
`void` `setLogFile(com.intersystems.jdbc.LogFileStream lf)` Sets a `LogFileStream` as the current log file.
`void` `setLogFile(String fileName)` Sets an `String` representing the current log file path.
`protected void` `setLogFileNoThrow(String fileName)`
`void` `setLoginTimeout(int seconds)` Sets the maximum time, in seconds, that the driver will wait for to obtain a connection before throwing a SQLException.
`void` `setLogWriter(PrintWriter pw)` Sets a `PrintWriter` as the current log file.
`void` `setNetworkTimeout(int timeout)` Sets the networkTimeout for this `DataSource` object.
`void` `setNodelay(boolean noDelay)` Sets the TCP_NODELAY flag for this `DataSource` object.
`void` `setPassword(String pwd)` Sets the password for this `DataSource` object.
`void` `setPortNumber(int portNumber)` Sets the port number for this `DataSource` object.
`void` `setPreparseCacheSize(int size)` Sets the Preparsed Cache size for this `DataSource` object.
`void` `setServerName(String serverName)` Sets the server name for this `DataSource` object.
`void` `setServicePrincipalName(String name)` Sets the Service Principal Name for this `DataSource` object.
`void` `setSSLConfigurationName(String name)` Sets the SSL Configuration Name for this `DataSource` object.
`void` `setStreamPrefetchSize(int size)` Sets the StreamPrefetch size for this `DataSource` object.
`void` `setURL(String u)` Sets the url for this `DataSource` object.
`void` `setUser(String user)` Sets the username for this `DataSource` object.

### Methods inherited from class com.intersystems.jdbc.ConnectionParameters

`addToPool, clone, copy, getHash, getSQLDialect, getTransactionIsolationLevel, isPooled, setSharedMemory, setSQLDialect, setTransactionIsolationLevel, updateConParams`

### Methods inherited from class com.intersystems.jdbc.IRISWrapper

`isWrapperFor, unwrap`

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

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

### Methods inherited from interface javax.sql.CommonDataSource

`getLogWriter, setLogWriter`

### Methods inherited from interface java.sql.Wrapper

`isWrapperFor, unwrap`

### Field Detail

#### logFile

    protected com.intersystems.jdbc.LogFileStream logFile

### Constructor Detail

#### IRISDataSource

    public IRISDataSource()

### Method Detail

#### getConnection

    public Connection getConnection()
                             throws SQLException

Specified by:
  `getConnection` in interface `DataSource`
Throws:
  `SQLException`

#### getConnection

    public Connection getConnection(String usr,
                                    String pwd)
                             throws SQLException

Specified by:
  `getConnection` in interface `DataSource`
Throws:
  `SQLException`

#### setUser

    public void setUser(String user)

Sets the username for this `DataSource` object.

Parameters:
  `user` - username

#### setPassword

    public void setPassword(String pwd)

Sets the password for this `DataSource` object.

Parameters:
  `pwd` - password

#### setAccessToken

    public void setAccessToken(String token)
                        throws SQLException

Sets the AccessToken for this `DataSource` object.

Parameters:
  `token` - accesstoken
Throws:
  `SQLException`

#### setServerName

    public void setServerName(String serverName)

Sets the server name for this `DataSource` object.

Overrides:
  `setServerName` in class `com.intersystems.jdbc.ConnectionParameters`
Parameters:
  `serverName` - Host name of the server

#### setPortNumber

    public void setPortNumber(int portNumber)

Sets the port number for this `DataSource` object.

Overrides:
  `setPortNumber` in class `com.intersystems.jdbc.ConnectionParameters`
Parameters:
  `portNumber` - port address on host

#### setDatabaseName

    public void setDatabaseName(String databaseName)

Sets Database (InterSystems IRIS Namespace) name for this `DataSource` object.

Overrides:
  `setDatabaseName` in class `com.intersystems.jdbc.ConnectionParameters`
Parameters:
  `databaseName` - namespace

#### setEventClass

    public void setEventClass(String eventClassName)

Sets the Event Class for this `DataSource` object.

Event Classes are an optional mechanism specific to InterSystems IRIS JDBC. Event Classes are Objectscript classes that extend `%Library.ServerEvent` and implements the `%OnTranCommit` and `%OnTranRollback` methods. When an event class is specified, the InterSystems IRIS JDBC will dispatch to the `%OnTranCommit` and `%OnTranRollback` just prior to committing or rolling back the current transaction. Neither method can abort the current transaction nor return any values.

The vast majority of applications will not need this feature.

Parameters:
  `eventClassName` - - The Event Class Name, e.g. "User.CustomServerEvent"

#### setNetworkTimeout

    public void setNetworkTimeout(int timeout)

Sets the networkTimeout for this `DataSource` object.

Parameters:
  `timeout` - networkTimeout in milliseconds

#### setCommitTimeout

    public void setCommitTimeout(int timeout)

Sets the commitTimeout for this `DataSource` object.

Parameters:
  `timeout` - commitTimeout in milliseconds

#### setNodelay

    public void setNodelay(boolean noDelay)

Sets the TCP_NODELAY flag for this `DataSource` object.

Parameters:
  `noDelay` - tcp nodelay value

#### setConnectionSecurityLevel

    public void setConnectionSecurityLevel(int level)
                                    throws SQLException

Sets the Connection Security Level for this `DataSource` object.

Overrides:
  `setConnectionSecurityLevel` in class `com.intersystems.jdbc.ConnectionParameters`
Parameters:
  `level` - connection's security level (0) default, (10) ssl
Throws:
  `SQLException`

#### getLoginTimeout

    public int getLoginTimeout()

Gets the time, in seconds, that the driver will wait for to obtain a connection before throwing a SQLException.

The default login timeout corresponds with `java.sql.DriverManager.getLoginTimeout()`.

Specified by:
  `getLoginTimeout` in interface `CommonDataSource`
Returns:
  login timeout value in seconds

#### setLoginTimeout

    public void setLoginTimeout(int seconds)

Sets the maximum time, in seconds, that the driver will wait for to obtain a connection before throwing a SQLException.

Specified by:
  `setLoginTimeout` in interface `CommonDataSource`
Parameters:
  `seconds` - login max wait time

#### getDataSourceName

    public String getDataSourceName()

Returns a `String` representing the current Data Source Name.

Returns:
  Alias name for DataSource

#### setDataSourceName

    public void setDataSourceName(String dataSourceName)

Sets tthe Data Source Name for this `DataSource` object.

Parameters:
  `dataSourceName` - Name alias for DataSource

#### getDescription

    public String getDescription()

Returns a `String` representing the current description.

Returns:
  description of DataSource

#### setDescription

    public void setDescription(String desc)

Sets the description for this `DataSource` object.

Parameters:
  `desc` - Text to describe DataSource

#### getServicePrincipalName

    public String getServicePrincipalName()

Returns a `String` representing current Service Principal Name.

Returns:
  Kerberos service principal name

#### setServicePrincipalName

    public void setServicePrincipalName(String name)

Sets the Service Principal Name for this `DataSource` object.

Parameters:
  `name` - Kerberos service principal name

#### getSSLConfigurationName

    public String getSSLConfigurationName()

Returns a `String` representing current SSL Configuration Name.

Returns:
  SSL configuration name

#### setSSLConfigurationName

    public void setSSLConfigurationName(String name)

Sets the SSL Configuration Name for this `DataSource` object.

Parameters:
  `name` - SSL configuration name

#### getKeyRecoveryPassword

    public String getKeyRecoveryPassword()

Returns a `String` representing current Key Recovery Password.

Returns:
  SSL key recovery password

#### setKeyRecoveryPassword

    public void setKeyRecoveryPassword(String password)

Sets the Key Recovery Password for this `DataSource` object.

Parameters:
  `password` - SSL keyRecovery password

#### getDefaultTransactionIsolation

    public int getDefaultTransactionIsolation()

Returns an `int` representing current Default Transaction Isolation Level.

Returns:
  current default transaction isolation level

#### setDefaultTransactionIsolation

    public void setDefaultTransactionIsolation(int level)
                                        throws SQLException

Sets the default Transaction Isolation Level for this `DataSource` object.

Parameters:
  `level` - Transaction Isolation Level
Throws:
  `SQLException` - - Invalid transaction isolation level

#### getPreparseCacheSize

    public int getPreparseCacheSize()

Returns an `int` representing the Preparsed Cache size.

Returns:
  size of the Statement Preparse Cache

#### setPreparseCacheSize

    public void setPreparseCacheSize(int size)

Sets the Preparsed Cache size for this `DataSource` object.

Parameters:
  `size` - Max size allowed for preParsed cache of statements

#### getStreamPrefetchSize

    public int getStreamPrefetchSize()

Returns an `int` representing the Stream Prefetch size.

Returns:
  when data length is smaller than this number it will be returned inside the row rather than taking another round trip

#### setStreamPrefetchSize

    public void setStreamPrefetchSize(int size)

Sets the StreamPrefetch size for this `DataSource` object.

Parameters:
  `size` - Values smaller than this will return the stream data in the original fetch

#### getParentLogger

    public Logger getParentLogger()
                           throws SQLFeatureNotSupportedException

Specified by:
  `getParentLogger` in interface `CommonDataSource`
Throws:
  `SQLFeatureNotSupportedException`

#### getURL

    public String getURL()

Returns a `String` representing a current URL for this `DataSource` object.

Returns:
  url

#### setURL

    public void setURL(String u)
                throws SQLException

Sets the url for this `DataSource` object.

Parameters:
  `u` - url
Throws:
  `SQLException` - throws SQLException

#### getUser

    public String getUser()

Returns a `String` representing the current username.

Returns:
  username to connect

#### getPassword

    public String getPassword()

Returns a `String` representing the current password.

Returns:
  password

#### getAccessToken

    public String getAccessToken()

Returns a `String` representing the current AccessToken.

Returns:
  accesstoken

#### getServerName

    public String getServerName()

Returns a `String` representing the current host.

Returns:
  current host name

#### getPortNumber

    public int getPortNumber()

Returns an `int` representing the current port number.

Returns:
  port number of host to connect with

#### getDatabaseName

    public String getDatabaseName()

Returns a `String` representing the current database (InterSystems IRIS Namespace) name.

Returns:
  namespace

#### getEventClass

    public String getEventClass()

Returns a `String` representing the Event Class object.

Returns:
  event Class

#### getNodelay

    public boolean getNodelay()

Returns a `boolean` representing the current TCP_NODELAY flag setting.

Returns:
  tcp nodelay value

#### getConnectionSecurityLevel

    public int getConnectionSecurityLevel()

Returns an `int` representing current Connection Security Level setting.

Returns:
  connection security level

#### getSharedMemory

    public Boolean getSharedMemory()

Returns an `boolean` representing whether or not shared memory connections are enabled for this `DataSource` object.

Returns:
  shared memory requested

#### getLogFile

    public com.intersystems.jdbc.LogFileStream getLogFile()

Returns a `LogFileStream` as the current log file instance.

Returns:
  instance of stream that writes a log

#### getFeatureOption

    public int getFeatureOption()

Returns an `int` representing the current Feature Option setting.

#### setFeatureOption

    public void setFeatureOption(int feature)
                          throws SQLException

Sets the current Feature Option setting.

The only permitted values are 0, 1, 2, 3... found in Feature.optionAllowedOptions.

Throws:
  `SQLException` - if `feature` is not in Feature.optionAllowedOptions.

#### setFeatureOption

    public void setFeatureOption(String sfeature)
                          throws SQLException

Sets the current Feature Option setting.

The only permitted values are 0, 1, 2, 3... found in Feature.optionAllowedOptions.

Throws:
  `SQLException` - if `feature` is not in Feature.optionAllowedOptions.

#### setLogFile

    public void setLogFile(String fileName)
                    throws SQLException

Sets an `String` representing the current log file path.

Parameters:
  `fileName` - path and filename of log file to use Use "" value to disable logging
Throws:
  `SQLException` - - Invalid log file name

#### setLogFileNoThrow

    protected void setLogFileNoThrow(String fileName)

#### setLogFile

    public void setLogFile(com.intersystems.jdbc.LogFileStream lf)

Sets a `LogFileStream` as the current log file.

Parameters:
  `lf` - instance of a logfileStream to use

#### getLogWriter

    public PrintWriter getLogWriter()

Returns a `PrintWriter` as the current log file instance.

Returns:
  printWriter for logging instance

#### setLogWriter

    public void setLogWriter(PrintWriter pw)

Sets a `PrintWriter` as the current log file.

Parameters:
  `pw` - sets logfile to use this PrintWriter

#### getLogFileName

    public String getLogFileName()

Returns a `String` representing the current log file path.

Returns:
  path and name of log file