com.ibm.ims.jdbc
Class IMSDataSource
- java.lang.Object
-
- com.ibm.ims.jdbc.IMSDataSource
-
- All Implemented Interfaces:
- java.sql.Wrapper, javax.sql.CommonDataSource, javax.sql.DataSource
public class IMSDataSource extends java.lang.Object implements javax.sql.DataSource
A factory for connections to IMS databases. This class implements thejavax.sql.DataSource
interface for the IMS Universal JDBC driver.
-
-
Field Summary
Fields Modifier and Type Field and Description static int
DRIVER_TYPE_2
Constant indicating usage of the type 2 driverstatic int
DRIVER_TYPE_4
Constant indicating usage of the type 4 driverstatic short
TRACE_ALL
Constant indicating to turn on all Universal driver tracingstatic short
TRACE_DLI
Constant indicating to turn on DLI layer tracingstatic short
TRACE_DRDA
Constant indicating to turn on DRDA layer tracingstatic short
TRACE_JDBC
Constant indicating to turn on JDBC layer tracingstatic short
TRACE_JEE
Constant indicating to turn on JEE layer tracingstatic short
TRACE_JEE
Constant indicating to turn on JEE layer tracing
-
Constructor Summary
Constructors Constructor and Description IMSDataSource()
The default constructor.
-
Method Summary
Methods Modifier and Type Method and Description java.sql.Connection
getConnection()
Attempts to establish a connection with the data source that this DataSource object represents.java.sql.Connection
getConnection(java.lang.String username, java.lang.String password)
Attempts to establish a connection with the data source that this DataSource object represents.java.lang.String
getDatabaseName()
Retrieves the database name this DataSource is configured to access.java.lang.String
getDatastoreName()
Retrieves name of the IMS datastore this DataSource is configured to access.java.lang.String
getDatastoreServer()
Retrieves the name or IP address of your datastore server (IMS Connect).java.lang.String
getDescription()
Retrieves the description of this DataSource.int
getDriverType()
Retrieves the database connectivity method.java.lang.String
getKeyStoreType()
Gets SSL key store type.int
getLoginTimeout()
Retrieves the login timeout for this DataSource objectjava.io.PrintWriter
getLogWriter()
Retrieves the log writer for this DataSource object.java.lang.String
getMetadataURL()
Deprecated.java.util.logging.Logger
getParentLogger()
java.lang.String
getPassword()
Retrieves the user password for RACF authentication.int
getPortNumber()
Retrieves the port number.java.util.Properties
getProperties()
Retrieves the Connection Properties.java.lang.String
getSecureSocketProtocol()
Gets SSL protocol.boolean
getSSLConnection()
Retrieves the SSL connectivity.java.lang.String
getSSLKeyStoreLocation()
Gets SSL key store path.java.lang.String
getSSLKeyStorePassword()
Gets SSL key store password.java.lang.String
getSSLTrustStoreLocation()
Gets SSL trust store path.java.lang.String
getSSLTrustStorePassword()
Gets SSL trust store password.java.lang.String
getUser()
Retrieves the user name for RACF authentication.boolean
isWrapperFor(java.lang.Class<?> iface)
This function is not supported.void
setDatabaseName(java.lang.String databaseName)
Sets the name of the target IMS database to be accessed.void
setDatastoreName(java.lang.String datastoreName)
Sets the name of the IMS datastore to access.void
setDatastoreServer(java.lang.String datastoreServer)
Sets the name or IP address of the datastore server (IMS Connect).void
setDescription(java.lang.String description)
Sets the description of this DataSource.void
setDriverType(int driverType)
Sets the type of driver to use to connect to the database.void
setHost(java.lang.String host)
PCB
setInitStatusGroup(java.lang.String initStatusGroup)
When a PSB is allocated, this property will indicate that the driver should automatically issue anINIT STATUS GROUPA
orINIT STATUS GROUPB
if a value of 'A' or 'B' is provided. The default will not issue anINIT STATUS GROUP
call.void
setKeyStoreType(java.lang.String keyStoreType)
Sets SSL key store type.void
setLoginTimeout(int seconds)
Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.void
setLogWriter(java.io.PrintWriter out)
Sets the log writer for thisDataSource
object to the givenjava.io.PrintWriter
object.void
setMetadataURL(java.lang.String metadataURL)
Deprecated.void
setPassword(java.lang.String password)
Sets the user password for RACF authentication.void
setPortNumber(int portNumber)
Sets the port number to be used to communicate with IMS Connect.void
setProperties(java.util.Properties properties)
Sets connection properties that are not part of the standard DataSource interface:dbspOncommit
: Set this property to true to deallocate the PSB when a commit occurs.fetchSize
: Gives the client a hint as to the number of rows that should be fetched from the database when more rows are needed.void
setSecureSocketProtocol(java.lang.String secureSocketProtocol)
Sets secure socket protocol type.void
setServerName(java.lang.String serverName)
void
setSSLConnection(boolean sslConnection)
Sets SSL encryption on or off.void
setSSLKeyStoreLocation(java.lang.String keyStoreLocation)
Sets SSL key store path.void
setSSLKeyStorePassword(java.lang.String keyStorePassword)
Sets SSL key store password.void
setSSLTrustStoreLocation(java.lang.String trustStoreLocation)
Sets SSL trust store path.void
setSSLTrustStorePassword(java.lang.String trustStorePassword)
Sets SSL trust store password.void
setUser(java.lang.String user)
Sets the user name for RACF authentication.java.lang.String
toString()
<T> T
unwrap(java.lang.Class<T> iface)
This function is no supported.
-
-
-
Field Detail
-
DRIVER_TYPE_4
public static final int DRIVER_TYPE_4
Constant indicating usage of the type 4 driver- See Also:
- Constant Field Values
-
DRIVER_TYPE_2
public static final int DRIVER_TYPE_2
Constant indicating usage of the type 2 driver- See Also:
- Constant Field Values
-
TRACE_ALL
public static final short TRACE_ALL
Constant indicating to turn on all Universal driver tracing- See Also:
- Constant Field Values
-
TRACE_DRDA
public static final short TRACE_DRDA
Constant indicating to turn on DRDA layer tracing- See Also:
- Constant Field Values
-
TRACE_DLI
public static final short TRACE_DLI
Constant indicating to turn on DLI layer tracing- See Also:
- Constant Field Values
-
TRACE_JDBC
public static final short TRACE_JDBC
Constant indicating to turn on JDBC layer tracing- See Also:
- Constant Field Values
-
TRACE_JEE
public static final short TRACE_JEE
Constant indicating to turn on JEE layer tracing- See Also:
- Constant Field Values
-
-
Method Detail
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLException
Attempts to establish a connection with the data source that this DataSource object represents.- Specified by:
getConnection
in interfacejavax.sql.DataSource
- Returns:
- a connection to the data source
- Throws:
java.sql.SQLException
-
getConnection
public java.sql.Connection getConnection(java.lang.String username, java.lang.String password) throws java.sql.SQLException
Attempts to establish a connection with the data source that this DataSource object represents.- Specified by:
getConnection
in interfacejavax.sql.DataSource
- Parameters:
username
- the database user on whose behalf the connection is being madepassword
- the user's password- Returns:
- a connection to the data source
- Throws:
java.sql.SQLException
-
getLogWriter
public java.io.PrintWriter getLogWriter() throws java.sql.SQLException
Retrieves the log writer for this DataSource object. The log writer is a character output stream to which all logging and tracing messages for this data source will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the java.sql.Drivermanager class. When a DataSource object is created, the log writer is initially null; in other words, the default is for logging to be disabled.- Specified by:
getLogWriter
in interfacejavax.sql.CommonDataSource
- Returns:
- the log writer for this data source or null if logging is disabled
- Throws:
java.sql.SQLException
-
getLoginTimeout
public int getLoginTimeout() throws java.sql.SQLException
Retrieves the login timeout for this DataSource object- Specified by:
getLoginTimeout
in interfacejavax.sql.CommonDataSource
- Returns:
- the login timeout
- Throws:
java.sql.SQLException
-
setLogWriter
public void setLogWriter(java.io.PrintWriter out) throws java.sql.SQLException
Sets the log writer for thisDataSource
object to the givenjava.io.PrintWriter
object. The log writer is a character output stream to which all logging and tracing messages for this data source will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source- specific log writer are not printed to the log writer associated with thejava.sql.Drivermanager
class. When aDataSource
object is created the log writer is initially null; in other words, the default is for logging to be disabled.- Specified by:
setLogWriter
in interfacejavax.sql.CommonDataSource
- Parameters:
out
- the new log writer; to disable logging, set to null- Throws:
java.sql.SQLException
-
setLoginTimeout
public void setLoginTimeout(int seconds)
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 aDataSource
object is created, the login timeout is initially zero.- Specified by:
setLoginTimeout
in interfacejavax.sql.CommonDataSource
- Parameters:
seconds
- the data source login time limit
-
setUser
public void setUser(java.lang.String user)
Sets the user name for RACF authentication.- Parameters:
user
- User name.
-
getUser
public java.lang.String getUser()
Retrieves the user name for RACF authentication.- Returns:
- the user name for this connection.
-
setPassword
public void setPassword(java.lang.String password)
Sets the user password for RACF authentication.- Parameters:
password
- User password value
-
getPassword
public java.lang.String getPassword()
Retrieves the user password for RACF authentication.- Returns:
- user password value for this connection
-
setProperties
public void setProperties(java.util.Properties properties) throws java.sql.SQLException
Sets connection properties that are not part of the standard DataSource interface:dbspOncommit
: Set this property to true to deallocate the PSB when a commit occurs.fetchSize
: Gives the client a hint as to the number of rows that should be fetched from the database when more rows are needed. The number of rows specified affects only data returned using this connection. If the value specified is zero, the hint is ignored.llfield
: Setting this property to true exposes the LL field data as a normal column in the result set.maxRows
: Specifies the maximum number of rows to return in a query result set.traceFile
: Specifies the name of the trace file for the connection.traceFileAppend
: If the specified trace file already exists, setting this property to true specifies that the trace data for the new connection should be appended to the existing trace file rather than overwriting it.traceDirectory
: Specifies the file system directory where the trace file is located.traceLevel
: Specifies the trace level for the connection.
These properties are optional.
- Parameters:
properties
- Connection Properties- Throws:
java.sql.SQLException
-
getProperties
public java.util.Properties getProperties()
Retrieves the Connection Properties.- Returns:
- Properties for this connection
-
setDatastoreServer
public void setDatastoreServer(java.lang.String datastoreServer)
Sets the name or IP address of the datastore server (IMS Connect). You can provide either the host name (for example, dev123.svl.ibm.com) or the IP address (for example, 192.166.0.2).NOTE: Only used for Type-4 connectivity. Does not apply for Type-2.
- Parameters:
datastoreServer
- name or IP address of the datastore server (IMS Connect)
-
getDatastoreServer
public java.lang.String getDatastoreServer()
Retrieves the name or IP address of your datastore server (IMS Connect).- Returns:
- the name or IP address of the datastore server (IMS Connect)
-
setPortNumber
public void setPortNumber(int portNumber)
Sets the port number to be used to communicate with IMS Connect. The port number is defined using the DRDAPORT parameter on the ODACCESS statement in the integrated IMS Connect configuration PROCLIB member.NOTE: Only used for Type-4 connectivity. Does not apply for Type-2.
- Parameters:
portNumber
- port number
-
getPortNumber
public int getPortNumber()
Retrieves the port number.- Returns:
- the port number for this connection.
-
setSSLConnection
public void setSSLConnection(boolean sslConnection)
Sets SSL encryption on or off.- Parameters:
sslConnection
- Set totrue
to turn SSL encryption on.
-
setSSLTrustStoreLocation
public void setSSLTrustStoreLocation(java.lang.String trustStoreLocation)
Sets SSL trust store path.- Parameters:
trustStoreLocation
- Fully qualified path to the key store file containing the trusted certificate from IMS Connect.
-
setSSLTrustStorePassword
public void setSSLTrustStorePassword(java.lang.String trustStorePassword)
Sets SSL trust store password.- Parameters:
trustStorePassword
- Password set for the key store file using keytool.
-
setSSLKeyStoreLocation
public void setSSLKeyStoreLocation(java.lang.String keyStoreLocation)
Sets SSL key store path.- Parameters:
keyStoreLocation
- Fully qualified path to the key store file containing the client's certificate and private key.
-
setSSLKeyStorePassword
public void setSSLKeyStorePassword(java.lang.String keyStorePassword)
Sets SSL key store password.- Parameters:
keyStorePassword
- Password set for the key store file using keytool.
-
setKeyStoreType
public void setKeyStoreType(java.lang.String keyStoreType)
Sets SSL key store type.- Parameters:
keyStoreType
- Valid values include "JKS" or "PKCS12".
-
setSecureSocketProtocol
public void setSecureSocketProtocol(java.lang.String secureSocketProtocol)
Sets secure socket protocol type.- Parameters:
secureSocketProtocol
- Valid values include "SSL", "SSLv3", "TLSv1.1", "TLSv1.2", etc.
-
getSSLConnection
public boolean getSSLConnection()
Retrieves the SSL connectivity.- Returns:
- true indicates SSL will be used, false indicates otherwise
-
getSSLTrustStoreLocation
public java.lang.String getSSLTrustStoreLocation()
Gets SSL trust store path.- Returns:
- trustStore path.
-
getSSLTrustStorePassword
public java.lang.String getSSLTrustStorePassword()
Gets SSL trust store password.- Returns:
- trustStore password.
-
getSSLKeyStoreLocation
public java.lang.String getSSLKeyStoreLocation()
Gets SSL key store path.- Returns:
- keyStore path.
-
getSSLKeyStorePassword
public java.lang.String getSSLKeyStorePassword()
Gets SSL key store password.- Returns:
- keyStore password.
-
getKeyStoreType
public java.lang.String getKeyStoreType()
Gets SSL key store type.- Returns:
- keyStore type.
-
getSecureSocketProtocol
public java.lang.String getSecureSocketProtocol()
Gets SSL protocol.- Returns:
- SSL protocol.
-
setMetadataURL
public void setMetadataURL(java.lang.String metadataURL)
Deprecated.setDatabaseName(String)
Sets the location of the database metadata representing the target IMS database. The metadata URL is the fully qualified name of the Java metadata class generated by the IMS Explorer for Development. The URL must begin with class://- Parameters:
metadataURL
- metadata url
-
getMetadataURL
public java.lang.String getMetadataURL()
Deprecated.getDatabaseName()
Retrieves the URL of the database metadata representing the target IMS database.- Returns:
- the metadata URL
-
setDescription
public void setDescription(java.lang.String description)
Sets the description of this DataSource.- Parameters:
description
- the description
-
getDescription
public java.lang.String getDescription()
Retrieves the description of this DataSource.- Returns:
- the description
-
setDatastoreName
public void setDatastoreName(java.lang.String datastoreName)
Sets the name of the IMS datastore to access. The datastore parameter must match either the name of the datastore defined to ODBM or be blank. The datastore name is defined in the ODBM CSLDCxxx PROCLIB member using either the DATASTORE (NAME=name) or ALIAS (NAME=aliasname) parameter. If the datastore value is left blank (or not supplied), IMS Connect will connect to any available instance of ODBM as it is assumed all datastores defined to ODBM are data shared.For Type-2 connectivity: The datastore parameter refers to the 1 to 4 character identifier of the DRA startup table member. The member name structure is DFSxxxx0 where xxxx is the member identifier. Example: datastore parameter = SYS1 refers to DRA startup table member DFSSYS10 The ODBA startup table is a user created member that contains the IMS subsystem connection properties which includes the IMS subsystem id. This is not required to be set for the Java Dependent Region runtime.
- Parameters:
datastoreName
- IMS datastore name
-
getDatastoreName
public java.lang.String getDatastoreName()
Retrieves name of the IMS datastore this DataSource is configured to access.- Returns:
- the datastore name
-
setDriverType
public void setDriverType(int driverType)
Sets the type of driver to use to connect to the database. Type-4: Distributed access over TCP/IP. Type-2: Local access (no TCP/IP).- Parameters:
driverType
- Supported values areIMSDataSource.DRIVER_TYPE_4
andIMSDataSource.DRIVER_TYPE_2
-
getDriverType
public int getDriverType()
Retrieves the database connectivity method.- Returns:
- the database connectivity method
-
setDatabaseName
public void setDatabaseName(java.lang.String databaseName)
Sets the name of the target IMS database to be accessed. If the metadata repository is the IMS catalog then the database name is the name of the PSB (program specification block) containing the database(s) to be accessed. If the metadata repository is the file system then the database name is the fully qualified name of the Java metadata class generated by the IMS Explorer for Development. In this case the name must begin with class://- Parameters:
databaseName
- database name
-
getDatabaseName
public java.lang.String getDatabaseName()
Retrieves the database name this DataSource is configured to access.- Returns:
- the database name
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
This function is not supported. Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does. Returns false otherwise. If this implements the interface then return true, else if this is a wrapper then return the result of recursively callingisWrapperFor
on the wrapped object. If this does not implement the interface and is not a wrapper, return false. This method should be implemented as a low-cost operation compared tounwrap
so that callers can use this method to avoid expensiveunwrap
calls that may fail. If this method returns true then callingunwrap
with the same argument should succeed.- Specified by:
isWrapperFor
in interfacejava.sql.Wrapper
- Parameters:
iface
- a Class defining an interface- Returns:
- true if this implements the interface or directly or indirectly wraps an object that does
- Throws:
java.sql.SQLException
- if an error occurs while determining whether this is a wrapper for an object with the given interface- Since:
- 1.6
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
This function is no supported. Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy. If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of callingunwrap
recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then anSQLException
is thrown.- Specified by:
unwrap
in interfacejava.sql.Wrapper
- Parameters:
iface
- a Class defining an interface that the result must implement- Returns:
- an object the implements the interface. May be a proxy for the actual implementing object.
- Throws:
java.sql.SQLException
- If no object found that implements the interface- Since:
- 1.6
-
setServerName
public void setServerName(java.lang.String serverName)
-
setHost
public void setHost(java.lang.String host)
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
- Specified by:
getParentLogger
in interfacejavax.sql.CommonDataSource
- Throws:
java.sql.SQLFeatureNotSupportedException
-
initStatusGroup
PCB setInitStatusGroup(java.lang.String initStatusGroup) throws DLIException
When a PSB is allocated, this property will indicate that the driver should automatically issue an INIT STATUS GROUPA or INIT STATUS GROUPB if a value of 'A' or 'B' is provided. The default will not issue an INIT STATUS GROUP call.- Parameters:
- initStatusGroup - The
INIT STATUS GROUP
value - Throws:
DLIException
- if the operation fails
-
-