org.d2rq.db.vendor
Class MySQL

java.lang.Object
  extended by org.d2rq.db.vendor.SQL92
      extended by org.d2rq.db.vendor.MySQL
All Implemented Interfaces:
Vendor

public class MySQL
extends SQL92

This syntax class implements MySQL-compatible SQL syntax.

Author:
Richard Cyganiak (richard@cyganiak.de)

Nested Class Summary
static class MySQL.MySQLCompatibilityBitDataType
           
static class MySQL.MySQLCompatibilityDateDataType
           
static class MySQL.MySQLCompatibilityTimeDataType
           
static class MySQL.MySQLCompatibilityTimestampDataType
           
 class MySQL.MySQLIdentifierParser
           
 
Nested classes/interfaces inherited from class org.d2rq.db.vendor.SQL92
SQL92.IdentifierParser, SQL92.PatternDoublingQuoter, 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
MySQL()
           
 
Method Summary
 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
 String getTrueTable()
          For databases that support SQL queries without a FROM clause, (SELECT 1+1), this should return null.
 Identifier[] parseIdentifiers(String s, int minParts, int maxParts)
          Parses SQL identifiers, such as column names and table names.
 String quoteStringLiteral(String s)
          Handles special characters in strings.
 String toString(Identifier identifier)
          Handles special characters in identifiers.
 
Methods inherited from class org.d2rq.db.vendor.SQL92
booleanExpressionToSimpleExpression, getAliasOperator, getRowNumLimitAsExpression, getRowNumLimitAsQueryAppendage, getRowNumLimitAsSelectModifier, initializeConnection, isIgnoredTable, quoteBinaryLiteral, quoteDateLiteral, quoteTimeLiteral, quoteTimestampLiteral, toQualifiedTableName, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySQL

public MySQL()
Method Detail

getConcatenationExpression

public String getConcatenationExpression(String[] sqlFragments)
Description copied from interface: Vendor
Concatenation of a and b is "a || b" in standard SQL, but CONCAT(a, b) in MySQL.

Specified by:
getConcatenationExpression in interface Vendor
Overrides:
getConcatenationExpression in class SQL92
Parameters:
sqlFragments - An array of SQL expressions to be concatenated
Returns:
A SQL expression that concatenates the arguments

getTrueTable

public String getTrueTable()
Description copied from interface: Vendor
For databases that support SQL queries without a 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.

Specified by:
getTrueTable in interface Vendor
Overrides:
getTrueTable in class SQL92

parseIdentifiers

public Identifier[] parseIdentifiers(String s,
                                     int minParts,
                                     int maxParts)
                              throws Identifier.IdentifierParseException
Description copied from interface: Vendor
Parses SQL identifiers, such as column names and table names. These might be qualified, that is, multiple period-separated identifiers. They might also be quoted if this is supported by the SQL syntax. For example, a fully qualified column name might be: MYCATALOG.MYSCHEMA."Table 1".ID

Specified by:
parseIdentifiers in interface Vendor
Overrides:
parseIdentifiers in class SQL92
Parameters:
s - The input string
minParts - Minimum required identifiers, e.g., 1 for an unqualified identifier
maxParts - Maximum required identifiers, e.g., 4 for a fully qualified column name
Returns:
Array of identifiers
Throws:
Identifier.IdentifierParseException - on invalid syntax

toString

public String toString(Identifier identifier)
Description copied from interface: Vendor
Handles special characters in identifiers. For example, SQL 92 puts delimited identifiers in double quotes, but MySQL uses backticks.

Specified by:
toString in interface Vendor
Overrides:
toString in class SQL92
Parameters:
identifier - An identifier, such as an unqualified table or column name
Returns:
A string representation of the identifier for use in SQL statements

quoteStringLiteral

public String quoteStringLiteral(String s)
Description copied from interface: Vendor
Handles special characters in strings. Most databases wrap the string in single quotes, and escape single quotes by doubling them. Some databases also require doubling of backslashes.

Specified by:
quoteStringLiteral in interface Vendor
Overrides:
quoteStringLiteral in class SQL92
Parameters:
s - An arbitrary character string
Returns:
A quoted and escaped version safe for use in SQL statements

getDefaultConnectionProperties

public Properties getDefaultConnectionProperties()
Description copied from interface: Vendor
Returns a set of default connection properties to be used when connecting to this database engine type

Specified by:
getDefaultConnectionProperties in interface Vendor
Overrides:
getDefaultConnectionProperties in class SQL92
Returns:
A collection of properties

getDataType

public DataType getDataType(int jdbcType,
                            String name,
                            int size)
Description copied from interface: Vendor
Returns a 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.

Specified by:
getDataType in interface Vendor
Overrides:
getDataType in class SQL92
Parameters:
jdbcType - A java.sql.Types constant
name - The type name, as reported by java.sql metadata methods, normalized to uppercase
size - Character size of the type, or 0 if not applicable
Returns:
A compatible D2RQ DataType instance, or null if the vendor code is broken