net.spy.db
Class DatabaseMetaDataQuerySelector

java.lang.Object
  extended by net.spy.SpyObject
      extended by net.spy.db.DatabaseMetaDataQuerySelector
All Implemented Interfaces:
QuerySelector

public class DatabaseMetaDataQuerySelector
extends SpyObject
implements QuerySelector

Query selection by database product name. This implementation of QuerySelector works by finding the best match for the given Connection by DatabaseMetaData's getDatabaseProductName().

The following product names are mapped to their respective names in this implementation:

Driver driver nameQuery Name
PostgreSQLpgsql
Oracleoracle
Microsoft SQL Servermssql
MySQLmysql
DB2 UDB for AS/400db2
Informix Dynamic Serverinformix
INFORMIX-OnLineinformix

See Also:
SpyDB

Field Summary
 
Fields inherited from interface net.spy.db.QuerySelector
DEFAULT_QUERY
 
Constructor Summary
DatabaseMetaDataQuerySelector()
          Get an instance of DatabaseMetaDataQuerySelector.
 
Method Summary
 java.lang.String getQuery(java.sql.Connection conn, java.util.Map<java.lang.String,java.lang.String> queryMap)
          Get the query for the given connection.
protected  java.lang.String getQuery(java.lang.String name, java.util.Map<java.lang.String,java.lang.String> queryMap)
          Attempt to get a query in the given map by a name.
protected  void initNameMap()
          Initialize the prefix to name map.
protected  void registerNameMapping(java.lang.String prefix, java.lang.String name)
          Register a prefix -> name mapping.
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseMetaDataQuerySelector

public DatabaseMetaDataQuerySelector()
Get an instance of DatabaseMetaDataQuerySelector. This should really only be called from QuerySelectorFactory

Method Detail

initNameMap

protected void initNameMap()
Initialize the prefix to name map.


registerNameMapping

protected void registerNameMapping(java.lang.String prefix,
                                   java.lang.String name)
Register a prefix -> name mapping.

Parameters:
prefix - the prefix to match for a name
name - the name

getQuery

public java.lang.String getQuery(java.sql.Connection conn,
                                 java.util.Map<java.lang.String,java.lang.String> queryMap)
                          throws java.sql.SQLException
Description copied from interface: QuerySelector
Get the query for the given connection.

Specified by:
getQuery in interface QuerySelector
Parameters:
conn - the connection that wants the query
queryMap - the Map of queries by name
Returns:
the query (as a String), null if a suitable query can't be found
Throws:
java.sql.SQLException
See Also:
QuerySelector

getQuery

protected java.lang.String getQuery(java.lang.String name,
                                    java.util.Map<java.lang.String,java.lang.String> queryMap)
Attempt to get a query in the given map by a name.

Parameters:
name - the name against which to search
queryMap - the map containing the queries
Returns:
the query, or null if one cannot be found


Copyright © 1995-2006 SPY Internetworking. All Rights Reserved.