org.openmobileis.common.util.database
Class AbstractQueryManager

java.lang.Object
  |
  +--org.openmobileis.common.util.database.AbstractQueryManager

public abstract class AbstractQueryManager
extends java.lang.Object

Title: OpenMobileIS project source
Description: This class is ths super class of the queries It allows to execute queries through the db manager. A query is built with : A pattern : SQL query with variables Parameters : Values of the variables defined in the pattern For instance, the query "SELECT * FROM TABLE WHERE ROW1 = val1 AND ROW2 = val2 will have the following pattern : "SELECT * FROM TABLE WHERE ROW1 = %0% AND ROW2 = %1% and the following parameters : {"val1", "val2"}. Note that the name of the variables are a sequential number starting by 0 and inserted between two separators : % The Manager variable contains dbManager instance which provides services to be connected / disconnected to the database as well as a service to get a connection from the pool connection object.

Since:
JDK 1.1
Version:
1.0.
Author:
Philippe Delrieu

Constructor Summary
AbstractQueryManager()
           
 
Method Summary
protected  java.lang.String buildDynamicQuery(java.lang.String pattern, java.util.Hashtable variables)
           
protected  java.lang.String buildQuery(java.lang.String queryPattern, java.lang.String[] parameters)
          buildQuery() get the query pattern stored in queries and insert the parameters.
 void close()
          close() allows to close the database
abstract  void create(java.lang.String[] parameters)
           
abstract  void delete(java.lang.String[] parameters)
           
protected  java.sql.ResultSet executeDynamicQuery(java.lang.String queryPattern, java.util.Hashtable variables)
          executeQuery() allows to execute a query such as "SELECT * FROM TABLE") use SQL syntax to perform queries Connection is not close to keep the resulting resultset.
protected  void executeDynamicUpdate(java.lang.String queryPattern, java.util.Hashtable variables)
          executeUpdateQuery() allows to execute a query with INSERT, UPDATE or DELETE statements use SQL syntax to perform queries Connection is not close to keep the resulting resultset.
protected  java.sql.ResultSet executeQuery(java.lang.String queryPattern, java.lang.String[] parameters)
          executeQuery() allows to execute a query such as "SELECT * FROM TABLE") use SQL syntax to perform queries Connection is not close to keep the resulting resultset.
protected  void executeUpdate(java.lang.String queryPattern, java.lang.String[] parameters)
          executeUpdateQuery() allows to execute a query with INSERT, UPDATE or DELETE statements use SQL syntax to perform queries Close and garbage the connection and pending result.
 ManagerDB getDbManager()
          Returns the dbManager.
protected  java.lang.String makeSQLList(java.lang.String[] items)
           
 void registerManagerDB(ManagerDB manager)
           
abstract  void update(java.lang.String[] parameters)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractQueryManager

public AbstractQueryManager()
Method Detail

registerManagerDB

public void registerManagerDB(ManagerDB manager)

close

public void close()
close() allows to close the database
Parameters:
None -  
Returns:
None
Throws:
None -  

executeQuery

protected java.sql.ResultSet executeQuery(java.lang.String queryPattern,
                                          java.lang.String[] parameters)
executeQuery() allows to execute a query such as "SELECT * FROM TABLE") use SQL syntax to perform queries Connection is not close to keep the resulting resultset. It must be garbaged by calling ManagerDB.getManager().garbageOpenedConnection();;
Parameters:
String - representing the query
Returns:
ResultSet : don't forget to close the resultSet after using.
Throws:
SQLException -  

executeDynamicQuery

protected java.sql.ResultSet executeDynamicQuery(java.lang.String queryPattern,
                                                 java.util.Hashtable variables)
executeQuery() allows to execute a query such as "SELECT * FROM TABLE") use SQL syntax to perform queries Connection is not close to keep the resulting resultset. It must be garbaged by calling ManagerDB.getManager().garbageOpenedConnection();;
Parameters:
String - representing the query
Returns:
ResultSet : don't forget to close the resultSet after using.
Throws:
SQLException -  

executeUpdate

protected void executeUpdate(java.lang.String queryPattern,
                             java.lang.String[] parameters)
                      throws ServiceException
executeUpdateQuery() allows to execute a query with INSERT, UPDATE or DELETE statements use SQL syntax to perform queries Close and garbage the connection and pending result.
Parameters:
String - representing the query
Returns:
None
Throws:
SQLException -  

executeDynamicUpdate

protected void executeDynamicUpdate(java.lang.String queryPattern,
                                    java.util.Hashtable variables)
                             throws ServiceException
executeUpdateQuery() allows to execute a query with INSERT, UPDATE or DELETE statements use SQL syntax to perform queries Connection is not close to keep the resulting resultset. It must be garbaged by calling ManagerDB.getManager().garbageOpenedConnection();;
Parameters:
String - representing the query
Returns:
None
Throws:
SQLException -  

buildDynamicQuery

protected java.lang.String buildDynamicQuery(java.lang.String pattern,
                                             java.util.Hashtable variables)

buildQuery

protected java.lang.String buildQuery(java.lang.String queryPattern,
                                      java.lang.String[] parameters)
buildQuery() get the query pattern stored in queries and insert the parameters.
Parameters:
String - QueryPattern representing the query with the variables
String - parameters representing the variable values or piece of sql codes %x% represents a variable and %code% represents a piece of sql code to replace
Returns:
String : definitive query
Throws:
java.lang.Exception -  

makeSQLList

protected java.lang.String makeSQLList(java.lang.String[] items)

create

public abstract void create(java.lang.String[] parameters)
                     throws ServiceException

delete

public abstract void delete(java.lang.String[] parameters)
                     throws ServiceException

update

public abstract void update(java.lang.String[] parameters)
                     throws ServiceException

getDbManager

public ManagerDB getDbManager()
Returns the dbManager.
Returns:
ManagerDB


Copyright 2005 e-Care. All Rights Reserved.