- java.lang.Object
-
- org.tentackle.sql.AbstractBackend
-
- org.tentackle.sql.AbstractSql92Backend
-
- org.tentackle.sql.Informix
-
- All Implemented Interfaces:
Backend
@Service(Backend.class) public class Informix extends AbstractSql92Backend
Backend for Informix.- Author:
- harald
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSQL_FIRSTFIRST string.static java.lang.StringSQL_FIRST_PARFIRST string.static java.lang.StringSQL_NVLNVL keyword.static java.lang.StringSQL_SKIPSKIP string.static java.lang.StringSQL_SKIP_PARSKIP string.-
Fields inherited from class org.tentackle.sql.AbstractSql92Backend
RESERVED_WORDS_SQL92, SQL_COALESCE, SQL_FOR_UPDATE
-
Fields inherited from class org.tentackle.sql.AbstractBackend
EMPTY_STRING, TYPE_BIGINT, TYPE_BIT, TYPE_BLOB, TYPE_BOOL, TYPE_BOOLEAN, TYPE_BYTE, TYPE_BYTEA, TYPE_CHAR_1, TYPE_CLOB, TYPE_DATE, TYPE_DATETIME, TYPE_DATETIME_YEAR_TO_SECOND, TYPE_DECIMAL, TYPE_DECIMAL_19, TYPE_DOUBLE, TYPE_FLOAT, TYPE_FLOAT4, TYPE_FLOAT8, TYPE_INT, TYPE_INT2, TYPE_INT4, TYPE_INT8, TYPE_INTEGER, TYPE_NCHAR_1, TYPE_NUMBER, TYPE_NUMBER_1, TYPE_NUMBER_10, TYPE_NUMBER_19, TYPE_NUMBER_5, TYPE_NVARCHAR, TYPE_NVARCHAR_MAX, TYPE_REAL, TYPE_SMALLFLOAT, TYPE_SMALLINT, TYPE_TEXT, TYPE_TIME, TYPE_TIMESTAMP, TYPE_TINYINT, TYPE_VARBINARY_MAX, TYPE_VARCHAR
-
Fields inherited from interface org.tentackle.sql.Backend
SQL_ALLSTAR, SQL_AND, SQL_ANDNOT, SQL_COMMA, SQL_COMMA_PAR, SQL_DELETE, SQL_EQUAL, SQL_EQUAL_PAR, SQL_EQUAL_PAR_COMMA, SQL_EQUAL_ZERO, SQL_EXISTS, SQL_FROM, SQL_GREATER, SQL_GREATER_PAR, SQL_GREATEROREQUAL, SQL_GREATEROREQUAL_PAR, SQL_GROUPBY, SQL_INSERT_INTO, SQL_INSERT_VALUES, SQL_ISNOTNULL, SQL_ISNULL, SQL_LEFT_PARENTHESIS, SQL_LESS, SQL_LESS_PAR, SQL_LESSOREQUAL, SQL_LESSOREQUAL_PAR, SQL_LIKE, SQL_LIKE_PAR, SQL_MAX, SQL_MIN, SQL_NOT, SQL_NOTEQUAL, SQL_NOTEQUAL_PAR, SQL_NOTEQUAL_ZERO, SQL_NOTLIKE, SQL_NOTLIKE_PAR, SQL_OR, SQL_ORDERBY, SQL_ORNOT, SQL_PAR, SQL_PAR_COMMA, SQL_PLUS_ONE, SQL_RIGHT_PARENTHESIS, SQL_SELECT, SQL_SELECT_ALL_FROM, SQL_SET, SQL_SORTASC, SQL_SORTDESC, SQL_UPDATE, SQL_WHERE, SQL_WHEREALL, SQL_WHEREAND, SQL_WHERENOTHING, SQL_WHEREOR
-
-
Constructor Summary
Constructors Constructor Description Informix()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildSelectSql(java.lang.StringBuilder sqlBuilder, boolean writeLock, int limit, int offset)Creates a select statement string from an inner sql string.java.sql.ConnectioncreateConnection(java.lang.String url, java.lang.String username, char[] password)Creates a jdbc connection.protected java.lang.StringextractWhereClause(java.lang.String sql, int whereOffset)Extracts the where clause from a given sql.java.lang.StringgetBackendId(java.sql.Connection connection)Determines the unique id or name used by the backend for a given connection.java.lang.StringgetCoalesceKeyword()Gets the keyword for the COALESCE function.java.lang.StringgetDriverClassName()Gets the JDBC driver class name.intgetMaxSize(SqlType sqlType)Returns the maximum size for a given SQL-type.java.lang.StringgetName()Gets the name of the backend.booleanisMatchingUrl(java.lang.String url)Checks whether the backend belongs to the given jdbc url.SqlType[]jdbcTypeToSqlType(int jdbcType, int size, int scale)Converts the JDBC data type integer to a tentackle backend SqlTypes.intsetLeadingSelectParameters(BackendPreparedStatement stmt, int limit, int offset)Sets optional parameters before applying the original parameters.intsetTrailingSelectParameters(BackendPreparedStatement stmt, int index, int limit, int offset)Sets optional parameters after applying the original parameters.java.lang.StringsqlAddColumn(java.lang.String tableName, java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Generates sql code to add a column.java.lang.StringsqlAlterColumnDefault(java.lang.String tableName, java.lang.String columnName, SqlType sqlType, java.lang.Object defaultValue)Generates sql code to change the default value a column.java.lang.StringsqlAlterColumnType(java.lang.String tableName, java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Generates sql code to change the datatype of a column.java.lang.StringsqlDropColumn(java.lang.String tableName, java.lang.String columnName)Generates sql code to drop a column.java.lang.StringsqlNextFromSequene(java.lang.String name)Creates the SQL string to retrieve the next id from a sequence.java.lang.StringsqlRenameColumn(java.lang.String tableName, java.lang.String oldColumnName, java.lang.String newColumnName)Generates sql code to rename a column.java.lang.StringsqlTypeToString(SqlType sqlType, int size)Converts the java SQL-type to the database type name.booleansupportsSequences()True if backend provides transactionless sequences.-
Methods inherited from class org.tentackle.sql.AbstractSql92Backend
getReservedWords, sqlCreateForeignKey, sqlDropForeignKey
-
Methods inherited from class org.tentackle.sql.AbstractBackend
allowsExpressionsReferringToTablesBeingUpdated, assertValidName, buildSelectSql, columnTypeNullDefaultToString, columnTypeToString, createColumnMetaData, createIndexColumnMetaData, createIndexMetaData, createTableMetaData, getDefaultSchema, getDefaultSize, getEmptyString, getMaxScale, getMetaData, getMigrationStrategy, getModelMetaData, getTableMetaData, isClobSupported, isCommunicationLinkException, isConstraintException, isDefaultEqual, isFilteredIndexSupported, isMatchingName, isReleaseSavepointSupported, isTemporaryName, needAliasForSubselect, needSetLongWorkaround, needTxForFetchsize, normalizeDefault, optimizeSql, sqlAlterColumnComment, sqlAlterColumnNullConstraint, sqlAlterTableComment, sqlAsBeforeTableAlias, sqlComment, sqlCreateColumn, sqlCreateColumnComment, sqlCreateIndex, sqlCreateTableAttributeWithoutComment, sqlCreateTableClosing, sqlCreateTableComment, sqlCreateTableIntro, sqlCreateTableIntroWithoutComment, sqlDropIndex, sqlFunction, sqlJoin, sqlJoinSelects, sqlJoinSelects, sqlRenameAndAlterColumnType, sqlRequiresExtraCommit, sqlResultSetIsClosedSupported, sqlUpdateToNotNull, toQuotedString, toString, valueToLiteral
-
-
-
-
Field Detail
-
SQL_NVL
public static final java.lang.String SQL_NVL
NVL keyword.- See Also:
- Constant Field Values
-
SQL_FIRST
public static final java.lang.String SQL_FIRST
FIRST string.- See Also:
- Constant Field Values
-
SQL_SKIP
public static final java.lang.String SQL_SKIP
SKIP string.- See Also:
- Constant Field Values
-
SQL_FIRST_PAR
public static final java.lang.String SQL_FIRST_PAR
FIRST string.- See Also:
- Constant Field Values
-
SQL_SKIP_PAR
public static final java.lang.String SQL_SKIP_PAR
SKIP string.- See Also:
- Constant Field Values
-
-
Method Detail
-
isMatchingUrl
public boolean isMatchingUrl(java.lang.String url)
Description copied from interface:BackendChecks whether the backend belongs to the given jdbc url.- Parameters:
url- the jdbc url- Returns:
- true if matches
-
getName
public java.lang.String getName()
Description copied from interface:BackendGets the name of the backend.- Returns:
- the name
-
getDriverClassName
public java.lang.String getDriverClassName()
Description copied from interface:BackendGets the JDBC driver class name.- Returns:
- the class name
-
getBackendId
public java.lang.String getBackendId(java.sql.Connection connection)
Description copied from interface:BackendDetermines the unique id or name used by the backend for a given connection.Useful to figure out the corresponding
ManagedConnectionfrom the backend's logfiles.- Parameters:
connection- the jdbc connection- Returns:
- the backend id, null if none
-
createConnection
public java.sql.Connection createConnection(java.lang.String url, java.lang.String username, char[] password) throws java.sql.SQLExceptionDescription copied from interface:BackendCreates a jdbc connection.- Specified by:
createConnectionin interfaceBackend- Overrides:
createConnectionin classAbstractBackend- Parameters:
url- the jdbc urlusername- the usernamepassword- the password- Returns:
- the created connection
- Throws:
java.sql.SQLException- if connection could not be established
-
getCoalesceKeyword
public java.lang.String getCoalesceKeyword()
Description copied from interface:BackendGets the keyword for the COALESCE function.- Specified by:
getCoalesceKeywordin interfaceBackend- Overrides:
getCoalesceKeywordin classAbstractSql92Backend- Returns:
- the keyword
-
buildSelectSql
public void buildSelectSql(java.lang.StringBuilder sqlBuilder, boolean writeLock, int limit, int offset)Description copied from interface:BackendCreates a select statement string from an inner sql string.sqlBuilderis anything asFROM... WHERE... ORDER BY....
It is decorated with a leadingSELECTplus optional clauses like for the given parameters.- Specified by:
buildSelectSqlin interfaceBackend- Overrides:
buildSelectSqlin classAbstractSql92Backend- Parameters:
sqlBuilder- the sql builder, initially containing the inner sql without leadingSELECT.writeLock- true select should write locklimit- the limit value, ≤ 0 if no limit clauseoffset- the offset value, ≤ 0 if no offset clause
-
setLeadingSelectParameters
public int setLeadingSelectParameters(BackendPreparedStatement stmt, int limit, int offset)
Description copied from interface:BackendSets optional parameters before applying the original parameters.- Specified by:
setLeadingSelectParametersin interfaceBackend- Overrides:
setLeadingSelectParametersin classAbstractSql92Backend- Parameters:
stmt- the prepared statementlimit- the limit value, ≤ 0 if no limit clauseoffset- the offset value, ≤ 0 if no offset clause- Returns:
- the next parameter index
-
setTrailingSelectParameters
public int setTrailingSelectParameters(BackendPreparedStatement stmt, int index, int limit, int offset)
Description copied from interface:BackendSets optional parameters after applying the original parameters.- Specified by:
setTrailingSelectParametersin interfaceBackend- Overrides:
setTrailingSelectParametersin classAbstractSql92Backend- Parameters:
stmt- the prepared statementindex- the first parameter indexlimit- the limit value, ≤ 0 if no limit clauseoffset- the offset value, ≤ 0 if no offset clause- Returns:
- the next parameter index
-
getMaxSize
public int getMaxSize(SqlType sqlType)
Description copied from interface:BackendReturns the maximum size for a given SQL-type.- Specified by:
getMaxSizein interfaceBackend- Overrides:
getMaxSizein classAbstractBackend- Parameters:
sqlType- the SQL-type- Returns:
- the maximum size, 0 if unlimited, -1 if type without size
-
sqlTypeToString
public java.lang.String sqlTypeToString(SqlType sqlType, int size)
Description copied from interface:BackendConverts the java SQL-type to the database type name.- Specified by:
sqlTypeToStringin interfaceBackend- Overrides:
sqlTypeToStringin classAbstractBackend- Parameters:
sqlType- the java sql typesize- the column's size- Returns:
- the corresponding type string
-
jdbcTypeToSqlType
public SqlType[] jdbcTypeToSqlType(int jdbcType, int size, int scale)
Description copied from interface:BackendConverts the JDBC data type integer to a tentackle backend SqlTypes.There may be more than one sqltype returned!
- Specified by:
jdbcTypeToSqlTypein interfaceBackend- Overrides:
jdbcTypeToSqlTypein classAbstractBackend- Parameters:
jdbcType- the jdbc data typesize- the column sizescale- the column's scale- Returns:
- the SqlTypes, empty array if no mapping available or no exact match (not generated by TT)
- See Also:
Types
-
supportsSequences
public boolean supportsSequences()
Description copied from interface:BackendTrue if backend provides transactionless sequences.- Specified by:
supportsSequencesin interfaceBackend- Overrides:
supportsSequencesin classAbstractSql92Backend- Returns:
- true if database supports sequences
-
sqlNextFromSequene
public java.lang.String sqlNextFromSequene(java.lang.String name)
Description copied from interface:BackendCreates the SQL string to retrieve the next id from a sequence.- Specified by:
sqlNextFromSequenein interfaceBackend- Overrides:
sqlNextFromSequenein classAbstractSql92Backend- Parameters:
name- the name of the sequence- Returns:
- the SQL code
-
sqlRenameColumn
public java.lang.String sqlRenameColumn(java.lang.String tableName, java.lang.String oldColumnName, java.lang.String newColumnName)Description copied from interface:BackendGenerates sql code to rename a column.- Specified by:
sqlRenameColumnin interfaceBackend- Overrides:
sqlRenameColumnin classAbstractBackend- Parameters:
tableName- the tablenameoldColumnName- the old column namenewColumnName- the new column name- Returns:
- the SQL code, null if need full spec sqlRenameAndAlterColumnType below
-
sqlAddColumn
public java.lang.String sqlAddColumn(java.lang.String tableName, java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Description copied from interface:BackendGenerates sql code to add a column.- Specified by:
sqlAddColumnin interfaceBackend- Overrides:
sqlAddColumnin classAbstractBackend- Parameters:
tableName- the tablenamecolumnName- the new column namecomment- optional comment, null if nonesqlType- the JDBC sql typesize- the optional sizescale- the optional scalenullable- true if NULL, else NOT NULLdefaultValue- the optional default value- Returns:
- the SQL code
-
sqlDropColumn
public java.lang.String sqlDropColumn(java.lang.String tableName, java.lang.String columnName)Description copied from interface:BackendGenerates sql code to drop a column.- Specified by:
sqlDropColumnin interfaceBackend- Overrides:
sqlDropColumnin classAbstractBackend- Parameters:
tableName- the tablenamecolumnName- the new column name- Returns:
- the SQL code
-
sqlAlterColumnType
public java.lang.String sqlAlterColumnType(java.lang.String tableName, java.lang.String columnName, java.lang.String comment, SqlType sqlType, int size, int scale, boolean nullable, java.lang.Object defaultValue)Description copied from interface:BackendGenerates sql code to change the datatype of a column.- Specified by:
sqlAlterColumnTypein interfaceBackend- Overrides:
sqlAlterColumnTypein classAbstractBackend- Parameters:
tableName- the tablenamecolumnName- the new column namecomment- optional comment, null if nonesqlType- the JDBC sql typesize- the optional sizescale- the optional scalenullable- true if NULL, else NOT NULLdefaultValue- the optional default value- Returns:
- the SQL code
-
sqlAlterColumnDefault
public java.lang.String sqlAlterColumnDefault(java.lang.String tableName, java.lang.String columnName, SqlType sqlType, java.lang.Object defaultValue)Description copied from interface:BackendGenerates sql code to change the default value a column.- Specified by:
sqlAlterColumnDefaultin interfaceBackend- Overrides:
sqlAlterColumnDefaultin classAbstractBackend- Parameters:
tableName- the tablenamecolumnName- the new column namesqlType- the JDBC sql typedefaultValue- the optional default value- Returns:
- the SQL code, null if need
Backend.sqlAlterColumnType(java.lang.String, java.lang.String, java.lang.String, org.tentackle.sql.SqlType, int, int, boolean, java.lang.Object)
-
extractWhereClause
protected java.lang.String extractWhereClause(java.lang.String sql, int whereOffset)Description copied from class:AbstractBackendExtracts the where clause from a given sql.- Overrides:
extractWhereClausein classAbstractBackend- Parameters:
sql- the sql statementwhereOffset- the location of WHERE in sql- Returns:
- the where clause without the keyword WHERE
-
-