|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.d2rq.db.vendor.SQL92
public class SQL92
This base class implements SQL-92 compatible syntax. Subclasses can override individual methods to implement different syntax.
Nested Class Summary | |
---|---|
static class |
SQL92.IdentifierParser
Parser for standard SQL92 identifiers. |
static class |
SQL92.PatternDoublingQuoter
|
static interface |
SQL92.Quoter
|
Field Summary |
---|
Fields inherited from interface org.d2rq.db.vendor.Vendor |
---|
HSQLDB, InterbaseOrFirebird, log, MSAccess, MySQL, Oracle, PostgreSQL, SQL92, SQLServer, Sybase |
Constructor Summary | |
---|---|
SQL92(boolean useAS)
Initializes a new instance. |
Method Summary | |
---|---|
Expression |
booleanExpressionToSimpleExpression(Expression expression)
In most databases, we don't have to do anything because boolean expressions are allowed anywhere. |
String |
getAliasOperator()
An alias declaration for use in FROM clauses. |
String |
getConcatenationExpression(String[] sqlFragments)
Concatenation of a and b is
"a || b " in standard SQL, but CONCAT(a, b)
in MySQL. |
DataType |
getDataType(int jdbcType,
String name,
int size)
Returns a DataType corresponding to a JDBC type. |
Properties |
getDefaultConnectionProperties()
Returns a set of default connection properties to be used when connecting to this database engine type |
Expression |
getRowNumLimitAsExpression(int limit)
Returns an expression for limiting the number of returned rows for engines that support this ( ROWNUM <= n ) |
String |
getRowNumLimitAsQueryAppendage(int limit)
Technically speaking, SQL 92 supports NO way of limiting result sets (ROW_NUMBER appeared in SQL 2003). |
String |
getRowNumLimitAsSelectModifier(int limit)
Returns a modifier for the SELECT keyword that adds a limit to the number of returned rows for engines that support this ( TOP n ) |
String |
getTrueTable()
For databases that support SQL queries without a FROM
clause, (SELECT 1+1 ), this should return null . |
void |
initializeConnection(Connection connection)
Vendor-specific initialization for a database connection. |
boolean |
isIgnoredTable(String catalog,
String schema,
String table)
TODO Use the Filter interface for this |
Identifier[] |
parseIdentifiers(String s,
int minParts,
int maxParts)
Parses SQL identifiers, such as column names and table names. |
String |
quoteBinaryLiteral(String hexString)
|
String |
quoteDateLiteral(String date)
|
String |
quoteStringLiteral(String s)
Handles special characters in strings. |
String |
quoteTimeLiteral(String time)
|
String |
quoteTimestampLiteral(String timestamp)
|
TableName |
toQualifiedTableName(String catalog,
String schema,
String table)
Returns a qualified table name from catalog/schema/table strings as reported from JDBC metadata. |
String |
toString(ColumnName column)
Handles special characters in qualified column names. |
String |
toString(Identifier identifier)
Handles special characters in identifiers. |
String |
toString(TableName table)
Handles special characters in qualified table names. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SQL92(boolean useAS)
useAS
- Use "Table AS Alias" or "Table Alias" in FROM clauses? In standard SQL, either is fine.Method Detail |
---|
public String getConcatenationExpression(String[] sqlFragments)
Vendor
a
and b
is
"a || b
" in standard SQL, but CONCAT(a, b)
in MySQL.
getConcatenationExpression
in interface Vendor
sqlFragments
- An array of SQL expressions to be concatenated
public String getAliasOperator()
Vendor
FROM
clauses.
Would return AS
for SQL 92, and a single space
for Oracle (the AS is optional in SQL 92, but some engines require
it, while others don't understand it).
getAliasOperator
in interface Vendor
public String getTrueTable()
Vendor
FROM
clause, (SELECT 1+1
), this should return null
.
For databases that require some sort of dummy table (e.g., Oracle:
SELECT 1+1 FROM DUAL
), this should return the name of
that table.
getTrueTable
in interface Vendor
public Identifier[] parseIdentifiers(String s, int minParts, int maxParts) throws Identifier.IdentifierParseException
Vendor
MYCATALOG.MYSCHEMA."Table 1".ID
parseIdentifiers
in interface Vendor
s
- The input stringminParts
- Minimum required identifiers, e.g., 1 for an unqualified identifiermaxParts
- Maximum required identifiers, e.g., 4 for a fully qualified column name
Identifier.IdentifierParseException
- on invalid syntaxpublic String toString(Identifier identifier)
Vendor
toString
in interface Vendor
identifier
- An identifier, such as an unqualified table or column name
public String toString(ColumnName column)
Vendor
toString
in interface Vendor
column
- A qualified column name
public String toString(TableName table)
Vendor
toString
in interface Vendor
table
- A qualified table name
public String quoteStringLiteral(String s)
Vendor
quoteStringLiteral
in interface Vendor
s
- An arbitrary character string
public String quoteBinaryLiteral(String hexString)
quoteBinaryLiteral
in interface Vendor
public String quoteDateLiteral(String date)
quoteDateLiteral
in interface Vendor
public String quoteTimeLiteral(String time)
quoteTimeLiteral
in interface Vendor
public String quoteTimestampLiteral(String timestamp)
quoteTimestampLiteral
in interface Vendor
public Expression getRowNumLimitAsExpression(int limit)
Vendor
ROWNUM <= n
)
getRowNumLimitAsExpression
in interface Vendor
limit
- A maximum number of rows, or Database.NO_LIMIT
Expression.TRUE
if not supported by the enginepublic String getRowNumLimitAsQueryAppendage(int limit)
getRowNumLimitAsQueryAppendage
in interface Vendor
limit
- A maximum number of rows, or Database.NO_LIMIT
public String getRowNumLimitAsSelectModifier(int limit)
Vendor
TOP n
)
getRowNumLimitAsSelectModifier
in interface Vendor
limit
- A maximum number of rows, or Database.NO_LIMIT
public Properties getDefaultConnectionProperties()
Vendor
getDefaultConnectionProperties
in interface Vendor
public DataType getDataType(int jdbcType, String name, int size)
Vendor
DataType
corresponding to a JDBC type. This may be
an unsupported datatype; in this case, its DataType.isUnsupported()
method will return true. null
will be returned if the vendor
code doesn't handle this datatype at all; that should generally be
considered a bug.
getDataType
in interface Vendor
jdbcType
- A java.sql.Types
constantname
- The type name, as reported by java.sql
metadata methods, normalized to uppercasesize
- Character size of the type, or 0 if not applicable
null
if the vendor code is brokenpublic Expression booleanExpressionToSimpleExpression(Expression expression)
booleanExpressionToSimpleExpression
in interface Vendor
expression
- A boolean expression
public boolean isIgnoredTable(String catalog, String schema, String table)
Vendor
isIgnoredTable
in interface Vendor
catalog
- A catalog name, or null
for the connection's default schemaschema
- A schema name, or null
for the connection's default schematable
- A table name
true
if this is a system table that doesn't contain user/application datapublic TableName toQualifiedTableName(String catalog, String schema, String table)
Vendor
toQualifiedTableName
in interface Vendor
catalog
- A catalog name, or null
for the connection's default schemaschema
- A schema name, or null
for the connection's default schematable
- A table name
public void initializeConnection(Connection connection) throws SQLException
Vendor
initializeConnection
in interface Vendor
SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |