public class AnsiStandard extends Object implements Dbms
Should there ever be such a thing then you wouldn't need to extend this, but all DBs used with Melati so far have needed to extend the standard with their own variations.
| Constructor and Description |
|---|
AnsiStandard() |
| Modifier and Type | Method and Description |
|---|---|
String |
alterColumnAddCommentSQL(Column<?> column,
String comment)
TODO test on something which actually uses this
|
String |
alterColumnNotNullableSQL(String tableName,
Column<?> column)
Return the SQL snippet to alter a column to not nullable.
|
String |
alterTableAddCommentSQL(Table<?> table,
String comment)
TODO test on something which actually uses this
|
String |
booleanTrueExpression(Column<Boolean> booleanColumn)
Accommodate lack of boolean types in underlying DBMS.
|
boolean |
canBeIndexed(Column<?> column)
MSSQL cannot index a TEXT column.
|
boolean |
canDropColumns()
Whether this DBMS can drop columns.
|
<S,O> PoemType<O> |
canRepresent(PoemType<S> storage,
PoemType<O> type)
Enable one PoemType to represent another,
for example a bit to represent a boolean.
|
boolean |
canStoreBlobs()
Whether this DBMS can store binary data.
|
String |
caseInsensitiveRegExpSQL(String term1,
String term2)
This is the Postgresql syntax.
|
String |
createTableOptionsSql()
Accomodate MySQL table creation options.
|
String |
createTableSql(Table<?> table) |
String |
createTableTypeQualifierSql(Table<?> table)
Allow Hsqldb to have a different create table syntax.
|
SQLPoemType<?> |
defaultPoemTypeOfColumnMetaData(ResultSet columnsMetaData)
The simplest POEM type corresponding to a JDBC description from the
database.
|
SQLPoemException |
exceptionForUpdate(Table<?> table,
PreparedStatement ps,
boolean insert,
SQLException e)
Version of previous method for PreparedStatements.
|
SQLPoemException |
exceptionForUpdate(Table<?> table,
String sql,
boolean insert,
SQLException e)
An exception appropriate for expressing what really went wrong
during a write to the db.
|
String |
getBinarySqlDefinition(int size)
Accommodate different treatment of different sized binary data.
|
Connection |
getConnection(String url,
String user,
String password)
The default windows installation of MySQL has autocommit set true,
which throws an SQLException when one issues a commit.
|
String |
getFixedPtSqlDefinition(int scale,
int precision)
Accommodate differing Fixed Point notations.
|
String |
getForeignKeyDefinition(String tableName,
String fieldName,
String targetTableName,
String targetTableFieldName,
String fixName)
If Foreign key definitions are part of field definitions,
otherwise blank (silently unsupported).
|
String |
getIndexLength(Column<?> column)
MySQL requires a length argument when creating an index on a BLOB or TEXT
column.
|
String |
getJdbcMetadataName(String name)
Some DBMSen (HSQLDB) use canonical uppercased names in the metadata but not
in normal use.
|
String |
getLongSqlDefinition()
Accommodate Long / Bigint deviants.
|
String |
getPrimaryKeyDefinition(String fieldName)
Return the PRIMARY KEY definition string for this dbms.
|
String |
getQuotedName(String name)
Accommodate different quoting strategies.
|
String |
getQuotedValue(SQLType<?> sqlType,
String value)
Accommodate different quoting strategies for values.
|
String |
getSchema()
The db schema name to use, if any.
|
String |
getSqlDefaultValue(SQLType<?> sqlType)
Used to set a not null value when
creating a non nullable column.
|
String |
getSqlDefinition(String sqlTypeName)
Retrieve a SQL type keyword used by the DBMS
for the given Melati type name.
|
String |
getStringSqlDefinition(int size)
Accommodate String / Text distinction.
|
String |
givesCapabilitySQL(Integer userTroid,
String capabilityExpr)
MySQL had no EXISTS keyword, from 4.1 onwards it does.
|
String |
melatiName(String name)
Reverse the mapping in unreservedName.
|
String |
preparedStatementPlaceholder(PoemType<?> type)
Accommodate casting in placeholders.
|
String |
selectLimit(String querySelection,
int limit)
Accommodate different limiting syntax.
|
void |
shutdown(Connection connection)
A no-op for all but hsqldb, where the db needs to be shutdown
when the servlet container or jvm is destroyed.
|
String |
sqlBooleanValueOfRaw(Object raw)
Accommodate different true and false values.
|
String |
tableInitialisationSql(Table<?> table) |
String |
toString()
A string to represent this DBMS.
|
void |
unloadDriver()
Used in tests to allow multiple dbmsen to be loaded and unloaded.
|
String |
unreservedName(String name)
A pair of functions for getting around keywords which make your
JDBC driver barf, as 'group' does for MySQL.
|
public void unloadDriver()
DbmsunloadDriver in interface Dbmspublic String getSchema()
Dbmspublic void shutdown(Connection connection) throws SQLException
Dbmsshutdown in interface DbmsSQLExceptionpublic boolean canDropColumns()
DbmscanDropColumns in interface Dbmspublic boolean canStoreBlobs()
DbmscanStoreBlobs in interface Dbmspublic Connection getConnection(String url, String user, String password) throws ConnectionFailurePoemException
getConnection in interface Dbmsurl - the jdbc URLuser - the user to connect as, may be nullpassword - the password for user, may be nullConnectionFailurePoemException - is we cannot connectpublic String preparedStatementPlaceholder(PoemType<?> type)
DbmspreparedStatementPlaceholder in interface Dbmstype - the PoemTypePostgresqlpublic String createTableSql(Table<?> table)
createTableSql in interface Dbmspublic String createTableTypeQualifierSql(Table<?> table)
DbmscreateTableTypeQualifierSql in interface Dbmspublic String createTableOptionsSql()
DbmscreateTableOptionsSql in interface Dbmspublic String tableInitialisationSql(Table<?> table)
tableInitialisationSql in interface Dbmspublic String getSqlDefinition(String sqlTypeName)
DbmsgetSqlDefinition in interface DbmssqlTypeName - the Melati internal type namepublic String getStringSqlDefinition(int size) throws SQLException
DbmsgetStringSqlDefinition in interface Dbmssize - the string length (-1 means no limit)SQLExceptionpublic String getLongSqlDefinition()
DbmsgetLongSqlDefinition in interface Dbmspublic String getBinarySqlDefinition(int size) throws SQLException
DbmsgetBinarySqlDefinition in interface Dbmssize - how big the field isSQLExceptionpublic String getFixedPtSqlDefinition(int scale, int precision) throws SQLException
DbmsgetFixedPtSqlDefinition in interface Dbmsscale - the number of places to right of decimal pointprecision - how many digits in totalSQLException - potentiallypublic String sqlBooleanValueOfRaw(Object raw)
DbmssqlBooleanValueOfRaw in interface Dbmspublic <S,O> PoemType<O> canRepresent(PoemType<S> storage, PoemType<O> type)
DbmscanRepresent in interface Dbmsstorage - the containertype - the type to storepublic SQLPoemType<?> defaultPoemTypeOfColumnMetaData(ResultSet columnsMetaData) throws SQLException
DbmsdefaultPoemTypeOfColumnMetaData in interface DbmscolumnsMetaData - the JDBC metadataSQLException - potentiallypublic SQLPoemException exceptionForUpdate(Table<?> table, String sql, boolean insert, SQLException e)
DbmsexceptionForUpdate in interface Dbmstable - The table on which the update was affectedsql - The operation attempted, or possibly nullinsert - Whether the operation was an INSERT as
opposed to an UPDATEe - The raw SQL exception: the routine is meant to
try to interpret e.getMessage if it canPostgresql.exceptionForUpdate(org.melati.poem.Table<?>, java.lang.String, boolean, java.sql.SQLException)public SQLPoemException exceptionForUpdate(Table<?> table, PreparedStatement ps, boolean insert, SQLException e)
DbmsexceptionForUpdate in interface Dbmstable - The table on which the update was affectedps - The operation attempted, or possibly nullinsert - Whether the operation was an INSERT as
opposed to an UPDATEe - The raw SQL exception: the routine is meant to
try to interpret e.getMessage if it canexceptionForUpdate(org.melati.poem.Table, java.lang.String,
boolean, java.sql.SQLException)public String getQuotedName(String name)
DbmsgetQuotedName in interface Dbmsname - the unquoted namepublic String getQuotedValue(SQLType<?> sqlType, String value)
DbmsgetQuotedValue in interface DbmssqlType - the SQLType of the valuevalue - the valuepublic String getJdbcMetadataName(String name)
DbmsgetJdbcMetadataName in interface Dbmsname - entity name such as tableinfopublic String unreservedName(String name)
unreservedName in interface Dbmsname - the field or table nameDbms.unreservedName(java.lang.String),
MySQL.unreservedName(java.lang.String),
MySQL.melatiName(java.lang.String)public String melatiName(String name)
DbmsmelatiName in interface Dbmsname - an SQL namepublic String getIndexLength(Column<?> column)
getIndexLength in interface Dbmscolumn - the POEM Column we are dealing withMySQL.getIndexLength(org.melati.poem.Column<?>)public boolean canBeIndexed(Column<?> column)
canBeIndexed in interface Dbmscolumn - the POEM Column we are dealing withpublic String givesCapabilitySQL(Integer userTroid, String capabilityExpr)
givesCapabilitySQL in interface DbmsuserTroid - the troid of the User to use in the querycapabilityExpr - the capability troid we needMySQL.givesCapabilitySQL(java.lang.Integer, java.lang.String)public String caseInsensitiveRegExpSQL(String term1, String term2)
caseInsensitiveRegExpSQL in interface Dbmsterm1 - the term to find interm2 - the quoted term to findpublic String toString()
Dbmspublic String getForeignKeyDefinition(String tableName, String fieldName, String targetTableName, String targetTableFieldName, String fixName)
DbmsgetForeignKeyDefinition in interface DbmstableName - the table that this column is in, unquotedfieldName - often the name of the foreign table, unquotedtargetTableName - the table that this is a foreign key into, unquotedtargetTableFieldName - name of the primary key field of the foreign
table, often id, unquotedfixName - name of the IntegrityFixpublic String getPrimaryKeyDefinition(String fieldName)
DbmsgetPrimaryKeyDefinition in interface DbmsfieldName - the table Troid column, often id, unquotedpublic String alterColumnNotNullableSQL(String tableName, Column<?> column)
DbmsalterColumnNotNullableSQL in interface Dbmspublic String selectLimit(String querySelection, int limit)
DbmsselectLimit in interface DbmsquerySelection - main body of querylimit - number to limit topublic String booleanTrueExpression(Column<Boolean> booleanColumn)
DbmsbooleanTrueExpression in interface DbmsbooleanColumn - the column which should be a booleanpublic String getSqlDefaultValue(SQLType<?> sqlType)
DbmsgetSqlDefaultValue in interface DbmssqlType - the type namepublic String alterColumnAddCommentSQL(Column<?> column, String comment)
alterColumnAddCommentSQL in interface Dbmscolumn - the target to add a remark tocomment - the remark to addpublic String alterTableAddCommentSQL(Table<?> table, String comment)
alterTableAddCommentSQL in interface Dbmstable - the target to add a remark tocomment - the remark to addCopyright © 2000–2021 PanEris. All rights reserved.