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

com.lapetus_ltd.api.db.control
Interface ILptsFactoryConnectionListener


public interface ILptsFactoryConnectionListener

Class Description : The listener to be implemented for control of connections.

This interface is used by the Connection Factory TLptsFactoryConnection to indicate that the status of a connection has changed.

When the connection factory initiateConnection is called, the result is a function or functions being called on this interface.
Every application should implement this interface as it provides control over new connections so that statements can be generated after a successful connection.
The other factory listeners for the statement and rowset work together with this listener, and are initiated from actions stemming from here.
These three factory listeners are the backbone of any dbJAPI application as they provide all the control required for achieving its requirements.

$LastChangedRevision: 1197 $
$LastChangedDate:: 2010-11-22 10:06:06#$


Method Summary
 void newConnectionCreated(TLptsConnection connection)
           This informs the listener that a new Connection has been made and established to a database.
 void newConnectionFailed(TLptsLog log)
           This informs the listener that a new Connection was not successful.
 void newConnectionProcessStarted()
           This is used to indicate that the connection process has started.
 void removedAndClosedConnection(TLptsConnection connection)
           Informs the listener that an existing connection has been removed and closed on the database.
 

Method Detail

newConnectionCreated

void newConnectionCreated(TLptsConnection connection)

This informs the listener that a new Connection has been made and established to a database.


This is the most appropriate place to initiate statements using TLptsFactoryStatement.createNewStatement(com.lapetus_ltd.api.db.control.TLptsConnection, com.lapetus_ltd._2009.xml.types.XLptsDBStatementType).
We have a new connection which is ready for executing statements and creating rowsets.
The rowset execution should take place in the statement factory listener implementation, when a new statement is successfully created.

Parameters:
connection - The new live connection to the DB.

newConnectionFailed

void newConnectionFailed(TLptsLog log)

This informs the listener that a new Connection was not successful.


The connection was not successful and the log supplied has the details with the exception from the DRIVER.
We need to make sure that the required driver files for the system are in the application directory, as this will cause fails.
The drivers are configured in a file called driver.loader.xml and is stored in the application directory.
Note that this may not be visible in the directory as the default is that it is put in the dbJAPI jar file.
A directory can be created called database and the files can be extracted from the JAR file for editing.
The driver directory needs to be in the application directory and the drivers declared in the driver.loader.xml file need to be present.
By default we have JAR driver files for Postgres, MS SQL and MySQL.

Parameters:
log - The log generated by the failure of the connection. It is also stored in the TLptsLogger log list.

newConnectionProcessStarted

void newConnectionProcessStarted()

This is used to indicate that the connection process has started.


This is normally used to initialise or lock dialogs while the DB connection is being made.
If the TLptsMainDatabase.setApplicationMainFrame(javax.swing.JFrame) has been set on the main frame of the application,
then the cursor will change to the WAIT mode until #newConnectionCreated, #newConnectionFailed or an error occurs.


removedAndClosedConnection

void removedAndClosedConnection(TLptsConnection connection)

Informs the listener that an existing connection has been removed and closed on the database.


If any statements are open on this connection, they are either closed or an error is generated, depending on the forceful in
TLptsFactoryConnection.removeConnection(connection, true/false for forceful).

Parameters:
connection - This is the connection that has been closed. Any action performed on this connection from here on out will cause an exception.


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