Returns a SQL identifier. If identifier
is a simple SQL identifier:
alwaysQuote
is
false
alwaysQuote
is
true
identifier
is not a simple SQL identifier, identifier
will be
enclosed in double quotes if not already present. If the datasource does
not support double quotes for delimited identifiers, the
identifier should be enclosed by the string returned from
DatabaseMetaData.getIdentifierQuoteString
. If the datasource
does not support delimited identifiers, a
SQLFeatureNotSupportedException
should be thrown.
A SQLException
will be thrown if identifier
contains any
characters invalid in a delimited identifier or the identifier length is
invalid for the datasource.
identifier | a SQL identifier | |
alwaysQuote | indicates if a simple SQL identifier should be returned as a quoted identifier |
SQLException | if identifier is not a valid identifier | |
SQLFeatureNotSupportedException | if the datasource does not support delimited identifiers | |
NullPointerException | if identifier is null |
@implSpec The default implementation uses the following criteria to determine a valid simple SQL identifier:
SQLException
if:
identifier
contains a null
character or double quote and is not
a simple SQL identifier. identifier
is less than 1 or greater than 128 characters
Examples of the conversion: identifier alwaysQuote Result Hello false Hello Hello true "Hello" G'Day false "G'Day" "Bruce Wayne" false "Bruce Wayne" "Bruce Wayne" true "Bruce Wayne" GoodDay$ false "GoodDay$" Hello"World false SQLException "Hello"World" false SQLException
Diagram: Statement