public class TrafT4DataSource extends T4DSProperties implements DataSource, Serializable, Referenceable
JDBC Type 4 Driver DataSource class.
Description: A DataSource object is a factory for Connection
objects. An object that implements the DataSource interface is
typically registered with a JNDI service provider. A JDBC driver that is
accessed through the DataSource API does not automatically
register itself with the DriverManager object.
The TrafT4DataSource class can provide connection pooling and
statement pooling features.
<b>Setting properties for the TrafT4DataSource in the Type 4 driver</b>
TrafT4DataSource ds = new TrafT4DataSource();
ds.setUrl("jdbc:t4jdbc://<NDCS host>:<NDCS port>/:");
ds.setCatalog("your catalog");
ds.setSchema("your schema");
ds.setUser("safeguard user name");
ds.setPassword("safeguard password");
// Following are optional properties
ds.setConnectionTimeout("timeout in seconds");
ds.setT4LogFile("your log file location");
ds.setT4LogLevel("SEVERE");
ds.setServerDataSource("NDCS datasource name");
// Properties relevant for Type 4 connection pooling.
// Set ds.setMaxPoolSize(-1) to turn OFF connection pooling
ds.setMaxPoolSize("number of connections required");
ds.setMinPoolSize("number of connections required");
// Properties relevant for Type 4 statement pooling.
// Set ds.setMaxStatement(0) to turn statement pooling OFF
// Statement pooling is enabled only when connection pooling is enabled.
ds.setMaxStatements("number of statements to be pooled");
<b>Programmatically registering TrafT4DataSource with JDNI</b>
java.util.Hashtable env = new java.util.Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "Factory class name here");
javax.naming.Context ctx = new javax.naming.InitialContext(env);
ctx.rebind("DataSource name here", ds);
<b>Application making Type4 connection using the DataSource from JDNI</b>
java.util.Hashtable env = new java.util.Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "Factory class name here");
javax.naming.Context ctx = new javax.naming.InitialContext(env);
DataSource ds = (DataSource)ctx.lookup("DataSource name here");
java.sql.Connection con = ds.getConnection();
Copyright: (C) Apache Software Foundation (ASF)
T4Properties,
Serialized Form| Constructor and Description |
|---|
TrafT4DataSource()
Contructor for the
TrafT4DataSource object. |
TrafT4DataSource(Properties info)
Contructor for the
TrafT4DataSource object. |
| Modifier and Type | Method and Description |
|---|---|
Connection |
getConnection()
Attempts to establish an NDCS connection.
|
Connection |
getConnection(String username,
String password)
Attempts to establish an NDCS connection.
|
String |
getNameType()
Deprecated.
|
Logger |
getParentLogger() |
Reference |
getReference() |
boolean |
isWrapperFor(Class iface) |
void |
setLogWriter(PrintWriter out)
Sets the print writer for the current Type 4 data source.
|
void |
setNameType(String nameType)
Deprecated.
|
Object |
unwrap(Class iface) |
getBlobTableName, getCatalog, getClobTableName, getConnectionTimeout, getDataSourceName, getDescription, getInitialPoolSize, getLocale, getLoginTimeout, getMaxIdleTime, getMaxPoolSize, getMaxStatements, getMinPoolSize, getNetworkTimeout, getReserveDataLocator, getRoundingMode, getSchema, getServerDataSource, getT4LogFile, getT4LogLevel, getUrl, getURL, getUser, setBlobTableName, setCatalog, setClobTableName, setConnectionTimeout, setConnectionTimeout, setDataSourceName, setDescription, setInitialPoolSize, setInitialPoolSize, setLoginTimeout, setLoginTimeout, setMaxIdleTime, setMaxIdleTime, setMaxPoolSize, setMaxPoolSize, setMaxStatements, setMaxStatements, setMinPoolSize, setMinPoolSize, setNetworkTimeout, setNetworkTimeout, setPassword, setReserveDataLocator, setReserveDataLocator, setRoundingMode, setRoundingMode, setSchema, setServerDataSource, setT4LogFile, setT4LogLevel, setUrl, setURL, setUsergetApplicationName, getCertificateDir, getCertificateFile, getCertificateFileActive, getCompression, getCpuToUse, getDelayedErrorMode, getKeepAlive, getKeepRawFetchBuffer, getLogWriter, getProperties, getReplacementString, getRoleName, getSessionName, getSPJEnv, getTcpNoDelay, getTokenAuth, setApplicationName, setCertificateDir, setCertificateFile, setCertificateFileActive, setCompression, setCompression, setCpuToUse, setCpuToUse, setDelayedErrorMode, setDelayedErrorMode, setKeepAlive, setKeepAlive, setKeepRawFetchBuffer, setKeepRawFetchBuffer, setReplacementString, setRoleName, setSessionName, setSPJEnv, setSPJEnv, setTcp_NoDelay, setTcpNoDelay, setTokenAuth, setTokenAuthclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLoginTimeout, getLogWriter, setLoginTimeoutpublic TrafT4DataSource()
TrafT4DataSource object.public TrafT4DataSource(Properties info)
TrafT4DataSource object.info - Contains all the Type 4 properties in a name,
value
pair.TrafT4DataSource(),
Propertiespublic Connection getConnection() throws SQLException
getConnection in interface DataSourceSQLException - if a database access error or NDCS error occurs.getConnection(String, String)public Connection getConnection(String username, String password) throws SQLException
getConnection in interface DataSourceusername - Safeguard user namepassword - Safeguard user passwordSQLException - if a database access error or NDCS error occurs.getConnection()public Reference getReference() throws NamingException
getReference in interface ReferenceableNamingExceptionpublic void setLogWriter(PrintWriter out) throws SQLException
setLogWriter in interface CommonDataSourcesetLogWriter in class T4Propertiesout - java.io.PrintWriter for the current T4 connection.SQLException - when error occurs.T4Properties.getLogWriter(),
ConnectionPoolDataSourcepublic void setNameType(String nameType)
public String getNameType()
public Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger in interface CommonDataSourceSQLFeatureNotSupportedExceptionpublic Object unwrap(Class iface) throws SQLException
unwrap in interface WrapperSQLExceptionpublic boolean isWrapperFor(Class iface) throws SQLException
isWrapperFor in interface WrapperSQLExceptionCopyright © 2017. All Rights Reserved.