Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)

com.lapetus_ltd.api.db.xml.types
Class TLptsDBConnectionType

java.lang.Object
  extended by com.lapetus_ltd._2009.xml.types.XLptsDBConnectionType
      extended by com.lapetus_ltd.api.db.xml.types.TLptsDBConnectionType

public class TLptsDBConnectionType
extends XLptsDBConnectionType

Class Description : The wrapper class for XLptsDBConnectionType.


This is one of two classes in dbJAPI that extends XLptsDBConnectionType, with the other being TLptsConnection.
The major difference between the two is that TLptsConnection implements java.sql.Connection.
So, you may ask why we have this class. Well it is used purely to initialise a XLptsDBConnectionType so that
it can be provided to TLptsConnection for the actual database connection (java.sql.Connection).

$LastChangedRevision: 1190 $
$LastChangedDate:: 2010-11-17 13:21:35#$


Field Summary
 
Fields inherited from class com.lapetus_ltd._2009.xml.types.XLptsDBConnectionType
charset, connectionString, credentials, dataFileUrl, driverType, holdabilityCode, holdabilityString, id, properties, timestamp, title, version
 
Constructor Summary
TLptsDBConnectionType()
           This constructor initiates DBConnectionType.
TLptsDBConnectionType(XLptsDBConnectionType connectionType)
           This constructor copies the connection type information from an XLptsDBConnectionType.
 
Method Summary
 
Methods inherited from class com.lapetus_ltd._2009.xml.types.XLptsDBConnectionType
getCharset, getConnectionString, getCredentials, getDataFileUrl, getDriverType, getHoldabilityCode, getHoldabilityString, getId, getProperties, getTimestamp, getTitle, getVersion, setCharset, setConnectionString, setCredentials, setDataFileUrl, setDriverType, setHoldabilityCode, setHoldabilityString, setId, setProperties, setTimestamp, setTitle, setVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TLptsDBConnectionType

public TLptsDBConnectionType()

This constructor initiates DBConnectionType.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never.

Notes : Default Constructor initiates DBConnectionType.

Example :

 ...
 TLptsDBConnectionType connectionType;
 

//Connect To PostgreSQL: Title of Connection, Class Name of Driver, The Name of the DB you want to connect, username and password for the db connectionType = connectToDB("POSTGRESQL BANK-DB","org.postgresql.ds.PGSimpleDataSource","bank","postgres","test"); if (connectionType!=null) { connectionPostgresId = connectionType.getId(); TLptsFactoryConnection.initiateConnection(connectionType); // This generates another thread!! } ...

private TLptsDBConnectionType connectToDB(String title, String driverClassName, String dbName, String username, String password) { TLptsDBConnectionType connectionType = new TLptsDBConnectionType(); connectionType.setTitle(title);

XLptsDriverType driverType = TLptsDriverLoader.getDriverTypeByClassName(driverClassName);

if (driverType==null) { System.out.println("Could not find driver for class : " + driverClassName); return null; }

TLptsDriverType dt = new TLptsDriverType(driverType);

// changing values that are default in the driver.loader.xml file. // the DB is now set correctly and will filter through to the Datasource interface execution if(dbName!=null) dt.setValueForInterfaceFunctionParameter("setDatabaseName","Database Name",dbName); connectionType.setDriverType(dt);

if(username==null || password==null) connectionType.setCredentials(TLptsCryptoUtil.defaultEncryptCredentialsRSA(driverType.getGuestUser(),driverType.getGuestPassword())); else connectionType.setCredentials(TLptsCryptoUtil.defaultEncryptCredentialsRSA(username,password));

return connectionType; }


TLptsDBConnectionType

public TLptsDBConnectionType(XLptsDBConnectionType connectionType)

This constructor copies the connection type information from an XLptsDBConnectionType.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never.

Notes : Use this function every time you need to copy or instantiate a type XLptsDBConnectionType class.

Example :

 ...
 TLptsDBConnectionType connectionType;
 

//Connect To PostgreSQL: Title of Connection, Class Name of Driver, The Name of the DB you want to connect, username and password for the db connectionType = connectToDB("POSTGRESQL BANK-DB","org.postgresql.ds.PGSimpleDataSource","bank","postgres","test"); if (connectionType!=null) { connectionPostgresId = connectionType.getId(); TLptsFactoryConnection.initiateConnection(connectionType); // This generates another thread!! } ...

private TLptsDBConnectionType connectToDB(String title, String driverClassName, String dbName, String username, String password) { TLptsDBConnectionType connectionType = new TLptsDBConnectionType(); connectionType.setTitle(title);

XLptsDriverType driverType = TLptsDriverLoader.getDriverTypeByClassName(driverClassName);

if (driverType==null) { System.out.println("Could not find driver for class : " + driverClassName); return null; }

TLptsDriverType dt = new TLptsDriverType(driverType);

// changing values that are default in the driver.loader.xml file. // the DB is now set correctly and will filter through to the Datasource interface execution if(dbName!=null) dt.setValueForInterfaceFunctionParameter("setDatabaseName","Database Name",dbName); connectionType.setDriverType(dt);

if(username==null || password==null) connectionType.setCredentials(TLptsCryptoUtil.defaultEncryptCredentialsRSA(driverType.getGuestUser(),driverType.getGuestPassword())); else connectionType.setCredentials(TLptsCryptoUtil.defaultEncryptCredentialsRSA(username,password));

return connectionType; }

Parameters:
connectionType - the class object to copy.


Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)