org.objectweb.telosys.dal.sql
Class ConnectionManager

java.lang.Object
  extended byorg.objectweb.telosys.dal.sql.ConnectionManager

public final class ConnectionManager
extends java.lang.Object

Unique (static) access point to get databases connections or databases sessions
This class manages 1 to N databases connection providers


Constructor Summary
ConnectionManager()
           
 
Method Summary
static java.sql.Connection getConnection()
          Returns a connection for the default database
static java.sql.Connection getConnection(int iBaseId)
          Returns a connection for the given database id
protected static ConnectionProvider getConnectionProvider()
          Returns the default database connection provider
protected static ConnectionProvider getConnectionProvider(int iBaseId)
          Return the connection provider for the given database id
static Database getDatabase(int id)
          Returns the database description for the given database id
static java.util.List getDatabases()
          Returns the list of all the databases managed by the current application
static int getDefaultDatabase()
          Returns the default database id
static DatabaseSession getDummySession()
          Returns a "dummy" database session.
static int getNumberOfDatabases()
          Returns the number of databases entries supported by the connection manager
including void entries
static int getPoolSize(int id)
          Returns the pool size for the given database id
or 0 if the database exists but doesn't use a Telosys pool ( ConnectionFactory or DataSource )
or -1 if there's no database for the given id
static java.lang.Class getProviderClass(int id)
          Returns the ConnectionProvider's class for the given database id.
static int getProviderType(int id)
          Returns the type of ConnectionProvider
one of the ConnectionProvider types : FACTORY, POOL, DATASOURCE
or NO_PROVIDER if there's no database for the given id
static DatabaseSession getSession()
          Returns a real database session for the default database id.
static DatabaseSession getSession(int iDatabaseId)
          Returns a real database session for the given database id.
static boolean init(java.io.InputStream is)
          Connection manager initialization
Load the 'databases configuration' XML and create a connection provider for each database definition
static boolean init(java.lang.String sFileName)
          Connection manager initialization
Load the 'dbcongif' XML file and create a connection provider for each database definition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionManager

public ConnectionManager()
Method Detail

init

public static boolean init(java.lang.String sFileName)
Connection manager initialization
Load the 'dbcongif' XML file and create a connection provider for each database definition

Parameters:
sFileName - : dbconfig file name
Returns:

init

public static boolean init(java.io.InputStream is)
Connection manager initialization
Load the 'databases configuration' XML and create a connection provider for each database definition

Parameters:
is - input stream of the XML configuration file
Returns:

getSession

public static DatabaseSession getSession()
                                  throws TelosysException
Returns a real database session for the default database id.

Returns:
Throws:
TelosysException

getSession

public static DatabaseSession getSession(int iDatabaseId)
                                  throws TelosysException
Returns a real database session for the given database id.

Parameters:
iDatabaseId -
Returns:
Throws:
TelosysException

getDummySession

public static DatabaseSession getDummySession()
Returns a "dummy" database session.

Returns:
Since:
v 1.0.2

getDefaultDatabase

public static int getDefaultDatabase()
Returns the default database id

Returns:

getNumberOfDatabases

public static int getNumberOfDatabases()
Returns the number of databases entries supported by the connection manager
including void entries

Returns:

getConnection

public static java.sql.Connection getConnection()
                                         throws TelosysException
Returns a connection for the default database

Returns:
Throws:
TelosysException

getConnection

public static java.sql.Connection getConnection(int iBaseId)
                                         throws TelosysException
Returns a connection for the given database id

Parameters:
iBaseId -
Returns:
Throws:
TelosysException

getConnectionProvider

protected static ConnectionProvider getConnectionProvider()
Returns the default database connection provider

Returns:

getConnectionProvider

protected static ConnectionProvider getConnectionProvider(int iBaseId)
Return the connection provider for the given database id

Parameters:
iBaseId -
Returns:
the connection provider (or null if no provider for the given DB id)

getDatabases

public static java.util.List getDatabases()
Returns the list of all the databases managed by the current application

Returns:
list of databases descriptions

getDatabase

public static Database getDatabase(int id)
Returns the database description for the given database id

Parameters:
id - the database id ( 0 to N )
Returns:
the database description or null
Since:
1.0.0

getPoolSize

public static int getPoolSize(int id)
Returns the pool size for the given database id
or 0 if the database exists but doesn't use a Telosys pool ( ConnectionFactory or DataSource )
or -1 if there's no database for the given id

Parameters:
id - the database id ( 0 to N )
Returns:
the size of the pool ( or 0 or -1 )
Since:
1.0.0

getProviderClass

public static java.lang.Class getProviderClass(int id)
Returns the ConnectionProvider's class for the given database id.

Parameters:
id - the database id ( 0 to N )
Returns:
the class or null if there's no database for the given id
Since:
1.0.0

getProviderType

public static int getProviderType(int id)
Returns the type of ConnectionProvider
one of the ConnectionProvider types : FACTORY, POOL, DATASOURCE
or NO_PROVIDER if there's no database for the given id

Returns:
Since:
1.0.0