org.openmobileis.common.util.database
Class AbstractQueryManager

java.lang.Object
  extended byorg.openmobileis.common.util.database.AbstractQueryManager
Direct Known Subclasses:
AtomicObjectQueryManager, HSQLSyncNumberQueryManager, JDBCGlobalPropertyQueryManager, MSSQLSyncNumberQueryManager, OracleSafeServerSyncNumberQueryManager, PostgreSQLSyncNumberQueryManager

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
protected  void executeBlobUpdate(java.lang.String queryPattern, java.lang.String[] parameters, byte[][] blobs)
          execute insert or update query with Blob data.
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)
           
 
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

Returns:
None
Throws:
None

executeBlobUpdate

protected void executeBlobUpdate(java.lang.String queryPattern,
                                 java.lang.String[] parameters,
                                 byte[][] blobs)
                          throws DatabaseException
execute insert or update query with Blob data. Query parameters are indicated with %0% tag and blob data with ? tag. Use SQL syntax to perform queries

Returns:
void
Throws:
DatabaseException

executeQuery

protected java.sql.ResultSet executeQuery(java.lang.String queryPattern,
                                          java.lang.String[] parameters)
                                   throws DatabaseException
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();;

Returns:
ResultSet : don't forget to close the resultSet after using.
Throws:
java.sql.SQLException
DatabaseException

executeDynamicQuery

protected java.sql.ResultSet executeDynamicQuery(java.lang.String queryPattern,
                                                 java.util.Hashtable variables)
                                          throws DatabaseException
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();;

Returns:
ResultSet : don't forget to close the resultSet after using.
Throws:
java.sql.SQLException
DatabaseException

executeUpdate

protected void executeUpdate(java.lang.String queryPattern,
                             java.lang.String[] parameters)
                      throws DatabaseException
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.

Returns:
None
Throws:
java.sql.SQLException
DatabaseException

executeDynamicUpdate

protected void executeDynamicUpdate(java.lang.String queryPattern,
                                    java.util.Hashtable variables)
                             throws DatabaseException
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();;

Returns:
None
Throws:
java.sql.SQLException
DatabaseException

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)
                               throws DatabaseException
buildQuery() get the query pattern stored in queries and insert the parameters.

Returns:
String : definitive query
Throws:
java.lang.Exception
DatabaseException

makeSQLList

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

getDbManager

public ManagerDB getDbManager()
Returns the dbManager.

Returns:
ManagerDB


Copyright 2006 OpenMobileIS. All Rights Reserved.