All Packages Class Hierarchy This Package Previous Next Index
Class org.xmlmiddleware.xmldbms.maps.factories.DBNameChecker
java.lang.Object
|
+----org.xmlmiddleware.xmldbms.maps.factories.DBNameChecker
- public class DBNameChecker
- extends Object
Checks if names conform to the rules of a particular database.
DBNameChecker checks that table and column names conform to the naming rules
of a particular database. It also checks that they do not collide with any table
or column names currently in the database or created in the current session. Names
are modified as follows:
- Any characters not supported by the database are discarded.
- The name is truncated to the maximum length allowed by the database.
- The case is changed to the case used by the database.
- Table names are checked against table names currently in the database, as
well as table names that have been created in the current session. Column
names are checked against the names in the current table. If any collisions
are found, a number (starting with 1) is appended to the name and the
result is re-checked until a non-colliding name is found.
If no database is specified, the legal character set is assumed to be a-z,
A-Z, 0-9, and _; the maximum length is assumed to be 30, the case used by
the database is assumed to be upper case, and the maximum number of columns
in a table is assumed to be 100.
- Version:
- 2.0
- Author:
- Ronald Bourret
-
DBNameChecker()
- Construct a new DBNameChecker.
-
DBNameChecker(Connection)
- Construct a new DBNameChecker and set the database connection.
-
checkColumnName(String, String, String, String)
- Checks a column name.
-
checkTableName(String, String, String)
- Checks a table name.
-
setConnection(Connection)
- Sets the database connection.
-
startNewSession()
- Start a new name-checking session.
DBNameChecker
public DBNameChecker()
- Construct a new DBNameChecker.
DBNameChecker
public DBNameChecker(Connection conn) throws SQLException
- Construct a new DBNameChecker and set the database connection.
- Parameters:
- conn - The Connection
- Throws: SQLException
- Thrown if an error occurs initializing the database
metadata.
setConnection
public void setConnection(Connection conn) throws SQLException
- Sets the database connection.
- Parameters:
- conn - The Connection. May be null.
- Throws: SQLException
- Thrown if an error occurs initializing the database
metadata.
startNewSession
public void startNewSession()
- Start a new name-checking session.
This method removes all names from the lists of table and column names
created during the previous session. Thus, names are checked for collisions
only against names created after this call and before the next call to
startNewSession().
checkTableName
public String checkTableName(String catalogName,
String schemaName,
String tableName) throws SQLException, XMLMiddlewareException
- Checks a table name.
If necessary, this method modifies the input table name to meet the naming criteria
of the current database.
- Parameters:
- catalogName - Name of the catalog in which to check for collisions. May be null.
- schemaName - Name of the schema in which to check for collisions. May be null.
- tableName - Table name to check.
- Returns:
- The modified table name.
- Throws: SQLException
- Thrown if an error occurs accessing the database.
- Throws: XMLMiddlewareException
- Thrown if an error occurs constructing a name.
checkColumnName
public String checkColumnName(String catalogName,
String schemaName,
String tableName,
String columnName) throws XMLMiddlewareException
- Checks a column name.
If necessary, this method modifies the input column name to meet the naming criteria
of the current database.
- Parameters:
- catalogName - Name of the catalog in which to check for collisions. May be null.
- schemaName - Name of the schema in which to check for collisions. May be null.
- tableName - Name of the table in which to check for collisions. The table name must
have been used in a call to checkTableName in this session.
- columnName - Column name to check.
- Returns:
- The modified column name.
- Throws: XMLMiddlewareException
- Thrown if an error occurs constructing a name.
All Packages Class Hierarchy This Package Previous Next Index