|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.ifeth.sehr.lib.SEHRDataSource
Simple object for accessing a firebird database within SEHR projects.
To access a SEHR database there are three basic, but different ways
1) using the SQL layer iBATIS
2) accessing the database by using 'java.sql' methods
3) using pooled connections
In any case the database must be connected first. This object can be used
either in SEHR server environments where the connection parameters are
available by the SEHRCfg.SEHRCfg()configuration
object or in a client environment by setting the parameters during object
initialization or by using the parameterless construcor together with some
setter methods.
Tip: If using 2) to access the database you should use
DAOJdbc.DAOJdbc(SEHRDataSource) as a layer between this datasource
connector and your application. The DAO provides some commonly used methods
for prepared statements in dependence to singleton or pooled connections,
executing prepared queries etc.;
In brief the DAO object will save some code to implement
java.sql methods.
To use pooled connection do
initPooledFBDS()connectToPool()to
establish a connection and get its indexgetPooledConnection(int)to get the
connection handle for usage with standard java.sql procedures
| Constructor Summary | |
SEHRDataSource()
Initiates a parameterless object instance for database connection To initialize later use init(SEHRCfg object) or initialize
manually by setter methods (e.g. on external client applications).
|
|
SEHRDataSource(SEHRCfg cfg)
Initiates an object instance with connection parameters using the SEHR configuratio object. |
|
SEHRDataSource(java.lang.String host,
int port,
java.lang.String database,
java.lang.String dblogin,
java.lang.String dbpw,
java.lang.String XMLpath)
Initiates an object instance with individual connection parameters This constructor is for clients, where a local SEHR configuration access by SEHRCfg is not available. |
|
SEHRDataSource(java.lang.String host,
java.lang.String port,
java.lang.String database,
java.lang.String dblogin,
java.lang.String dbpw)
Deprecated. If we're using the db layer 'iBatis' we need XML resources :) |
|
SEHRDataSource(java.lang.String host,
java.lang.String sport,
java.lang.String database,
java.lang.String dblogin,
java.lang.String dbpw,
java.lang.String XMLpath)
Initiates an object instance with individual connection parameters |
|
| Method Summary | |
void |
close()
Close the firebird datasource handle of current object. |
static void |
close(SEHRDataSource fbds)
Close the firebird datasource handle of the given object. |
void |
closeAll()
Close all pooled connections |
void |
closeFBDataSource()
Deprecated. use 'close(...)' |
static void |
closeFBDataSource(SEHRDataSource fbds)
Deprecated. use 'close(...)' |
java.sql.Connection |
connect()
Make a connection for the current firebird database source object assuming the parameters are already invoked by this object instance. |
static java.sql.Connection |
connect(SEHRDataSource fbds)
Make a connection for the given firebird database source object assuming the parameters are already invoked by the given 'fbds' object instance. |
java.sql.Connection |
connectFBDataSource()
Deprecated. use 'connect()' |
static java.sql.Connection |
connectFBDataSource(SEHRDataSource fbds)
Deprecated. use 'connect()' |
java.sql.Connection |
connectFBDataSource(SEHRDataSource fbds,
java.lang.String host,
java.lang.String port,
java.lang.String database,
java.lang.String dblogin,
java.lang.String dbpw)
Deprecated. use 'connect()' |
java.sql.Connection |
connectFBDataSource(java.lang.String host,
java.lang.String port,
java.lang.String database,
java.lang.String dblogin,
java.lang.String dbpw)
Deprecated. use 'connect()' |
int |
connectToPool()
Create a new pooled connection for current firebird database source object. * Note: Use closePooledConnection(int conidx)! |
int |
countExpectedPooledConnections()
Get number of currently pooled connections handled by object |
int |
countPooledConnections()
Get number of currently pooled connections by FB engine |
java.lang.String |
getDBHost()
For general usage: get host of db access |
java.util.List |
getGenerator()
|
java.util.List |
getGenerator(java.lang.String genid)
|
java.sql.Connection |
getHFBConnection()
Return the connection handle for the current datasource object. |
java.sql.Connection |
getHFBConnection(SEHRDataSource fbds)
Return the connection handle for given firebird datasource object |
java.sql.Connection |
getPooledConnection(int idx)
Get an already established connection from pool given by index. |
com.ibatis.sqlmap.client.SqlMapClient |
getSqlmap()
Get the initialized SQL mapping object of connected datasource This is the recommended object for accessng the database by its SQL objects; see example in main(String[])
|
void |
init()
Initialize SEHR environment for db connections by setting the configuration object The configuration holds some more informations like the XML mappings. |
void |
init(java.lang.String sehrcfgfile)
Initialize SEHR environment |
org.firebirdsql.jdbc.FBWrappingDataSource |
initPooledFBDS()
Init a pooled data connection |
boolean |
isPooledConnection()
Get status if a pooled datasource already in use |
static void |
main(java.lang.String[] args)
For testing purposes only... |
void |
setCfg(SEHRCfg cfg)
Set cfg object to use for datasource initialization |
void |
setDataBase(java.lang.String dataBase)
For client usage: set database including path_to_db_file |
void |
setDBHost(java.lang.String host)
For client usage: set port of firebird engine |
void |
setDBLogin(java.lang.String login)
For client usage: set database login name |
void |
setDBPort(int port)
For client usage: set port of firebird engine |
void |
setDBPw(java.lang.String pw)
For client usage: set database login password |
void |
setSqlMap(com.ibatis.sqlmap.client.SqlMapClient sqlmap)
Set SQL mapping object. |
java.lang.String |
showProcedures()
|
static java.lang.String |
showProcedures(SEHRDataSource fbds)
|
java.lang.String |
showTables()
|
java.lang.String |
showTables(boolean showfields)
|
static java.lang.String |
showTables(SEHRDataSource fbds)
|
static java.lang.String |
showTables(SEHRDataSource fbds,
boolean showfields)
|
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public SEHRDataSource()
To initialize later use init(SEHRCfg object) or initialize
manually by setter methods (e.g. on external client applications).
public SEHRDataSource(SEHRCfg cfg)
This is the recommended way on SEHR servers. To connect/open use
connectFBDataSource((Object) this)
public SEHRDataSource(java.lang.String host,
int port,
java.lang.String database,
java.lang.String dblogin,
java.lang.String dbpw,
java.lang.String XMLpath)
This constructor is for clients, where a local SEHR configuration access by
SEHRCfg is not available. There are two ways for the client to get the
parameters
1) by written papers and a local configuration :)
2) by using a SOAP or socket request to the server by IP and port
To connect/open use connectFBDataSource((Object) this)
host - port - database - dblogin - dbpw - XMLpath - if using 'iBatis' this is the path to the SQL-XML files
public SEHRDataSource(java.lang.String host,
java.lang.String sport,
java.lang.String database,
java.lang.String dblogin,
java.lang.String dbpw,
java.lang.String XMLpath)
SEHRDataSource(String, int, String, String, String, String)
public SEHRDataSource(java.lang.String host,
java.lang.String port,
java.lang.String database,
java.lang.String dblogin,
java.lang.String dbpw)
To connect/open use connect()
host - port - database - dblogin - dbpw - | Method Detail |
public void init()
The configuration holds some more informations like the XML mappings.
public void init(java.lang.String sehrcfgfile)
setCfg(SEHRCfg)public org.firebirdsql.jdbc.FBWrappingDataSource initPooledFBDS()
public java.sql.Connection connectFBDataSource()
public java.sql.Connection connectFBDataSource(java.lang.String host,
java.lang.String port,
java.lang.String database,
java.lang.String dblogin,
java.lang.String dbpw)
public java.sql.Connection connectFBDataSource(SEHRDataSource fbds,
java.lang.String host,
java.lang.String port,
java.lang.String database,
java.lang.String dblogin,
java.lang.String dbpw)
public static java.sql.Connection connectFBDataSource(SEHRDataSource fbds)
public java.sql.Connection connect()
public static java.sql.Connection connect(SEHRDataSource fbds)
This is the method finally called to connect
fbds -
public void closeFBDataSource()
throws java.sql.SQLException
java.sql.SQLException
public static void closeFBDataSource(SEHRDataSource fbds)
throws java.sql.SQLException
java.sql.SQLException
public void close()
throws java.sql.SQLException
java.sql.SQLException
public static void close(SEHRDataSource fbds)
throws java.sql.SQLException
fbds - FBDataSource object
java.sql.SQLException
public int connectToPool()
throws java.sql.SQLException
Note: Use closePooledConnection(int conidx)! Pooled connections do
have large benefits in c/s connections but there are also some traps. One
of these traps is the number and the maximum of pooled concurrent
connections. To get an overview of the number of real connections use
countPooledConnections(). To get
the number of managed connections use
countExpectedPooledConnections().
To close all connections at once use
closeAll()
To get established connection use
getPooledConnection(int idx)
java.sql.SQLExceptionpublic java.sql.Connection getPooledConnection(int idx)
To keep the integrity of prepared statements the pool is indexed. So you may init a connection, assign statements to it and use exactly the indexed connection to get your statementents back.
public void closeAll()
public int countPooledConnections()
public int countExpectedPooledConnections()
public boolean isPooledConnection()
public com.ibatis.sqlmap.client.SqlMapClient getSqlmap()
This is the recommended object for accessng the database by its SQL
objects; see example in main(String[])
public void setSqlMap(com.ibatis.sqlmap.client.SqlMapClient sqlmap)
public void setCfg(SEHRCfg cfg)
public void setDBPort(int port)
public java.lang.String getDBHost()
public void setDBHost(java.lang.String host)
public void setDataBase(java.lang.String dataBase)
public void setDBLogin(java.lang.String login)
public void setDBPw(java.lang.String pw)
public java.sql.Connection getHFBConnection()
public java.sql.Connection getHFBConnection(SEHRDataSource fbds)
fbds - FBDataSource object
public java.lang.String showTables()
public java.lang.String showTables(boolean showfields)
public static java.lang.String showTables(SEHRDataSource fbds)
public static java.lang.String showTables(SEHRDataSource fbds,
boolean showfields)
public java.lang.String showProcedures()
public static java.lang.String showProcedures(SEHRDataSource fbds)
public java.util.List getGenerator()
public java.util.List getGenerator(java.lang.String genid)
public static void main(java.lang.String[] args)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||