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 DbmsDbms.unloadDriver()public String getSchema()
DbmsgetSchema in interface DbmsDbms.getSchema()public void shutdown(Connection connection) throws SQLException
Dbmsshutdown in interface DbmsSQLExceptionDbms.shutdown(java.sql.Connection)public boolean canDropColumns()
canDropColumns in interface DbmsDbms.canDropColumns()public boolean canStoreBlobs()
canStoreBlobs in interface DbmsDbms.canStoreBlobs()public 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 connectDbms.getConnection(java.lang.String, java.lang.String, java.lang.String)public String preparedStatementPlaceholder(PoemType<?> type)
preparedStatementPlaceholder in interface Dbmstype - the PoemTypeDbms.preparedStatementPlaceholder(org.melati.poem.PoemType)public String createTableSql(Table<?> table)
createTableSql in interface Dbmspublic String createTableTypeQualifierSql(Table<?> table)
createTableTypeQualifierSql in interface DbmsDbms.createTableTypeQualifierSql(org.melati.poem.Table)public String createTableOptionsSql()
createTableOptionsSql in interface DbmsDbms.createTableOptionsSql()public String tableInitialisationSql(Table<?> table)
tableInitialisationSql in interface DbmsDbms.tableInitialisationSql(org.melati.poem.Table)public String getSqlDefinition(String sqlTypeName)
getSqlDefinition in interface DbmssqlTypeName - the Melati internal type nameDbms.getSqlDefinition(java.lang.String)public String getStringSqlDefinition(int size) throws SQLException
getStringSqlDefinition in interface Dbmssize - the string length (-1 means no limit)SQLExceptionDbms.getStringSqlDefinition(int)public String getLongSqlDefinition()
getLongSqlDefinition in interface DbmsDbms.getLongSqlDefinition()public String getBinarySqlDefinition(int size) throws SQLException
getBinarySqlDefinition in interface Dbmssize - how big the field isSQLExceptionDbms.getBinarySqlDefinition(int)public String getFixedPtSqlDefinition(int scale, int precision) throws SQLException
getFixedPtSqlDefinition in interface Dbmsscale - the number of places to right of decimal pointprecision - how many digits in totalSQLException - potentiallyDbms.getFixedPtSqlDefinition(int, int)public String sqlBooleanValueOfRaw(Object raw)
DbmssqlBooleanValueOfRaw in interface DbmsDbms.sqlBooleanValueOfRaw(java.lang.Object)public <S,O> PoemType<O> canRepresent(PoemType<S> storage, PoemType<O> type)
DbmscanRepresent in interface Dbmsstorage - the containertype - the type to storeDbms.canRepresent(org.melati.poem.PoemType, org.melati.poem.PoemType)public SQLPoemType<?> defaultPoemTypeOfColumnMetaData(ResultSet columnsMetaData) throws SQLException
DbmsdefaultPoemTypeOfColumnMetaData in interface DbmscolumnsMetaData - the JDBC metadataSQLException - potentiallyDbms.defaultPoemTypeOfColumnMetaData(java.sql.ResultSet)public SQLPoemException exceptionForUpdate(Table<?> table, String sql, boolean insert, SQLException e)
exceptionForUpdate 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 canDbms.exceptionForUpdate(org.melati.poem.Table<?>, java.lang.String, boolean, java.sql.SQLException)public SQLPoemException exceptionForUpdate(Table<?> table, PreparedStatement ps, boolean insert, SQLException e)
exceptionForUpdate 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 canDbms.exceptionForUpdate(org.melati.poem.Table,
java.sql.PreparedStatement,
boolean, java.sql.SQLException)public String getQuotedName(String name)
getQuotedName in interface Dbmsname - the unquoted nameDbms.getQuotedName(java.lang.String)public String getQuotedValue(SQLType<?> sqlType, String value)
DbmsgetQuotedValue in interface DbmssqlType - the SQLType of the valuevalue - the valuepublic String getJdbcMetadataName(String name)
getJdbcMetadataName in interface Dbmsname - entity name such as tableinfoDbms.getJdbcMetadataName(java.lang.String)public 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)
melatiName in interface Dbmsname - an SQL nameDbms.melatiName(java.lang.String)public String getIndexLength(Column<?> column)
getIndexLength in interface Dbmscolumn - the POEM Column we are dealing withDbms.getIndexLength(org.melati.poem.Column),
MySQL.getIndexLength(org.melati.poem.Column<?>)public boolean canBeIndexed(Column<?> column)
canBeIndexed in interface Dbmscolumn - the POEM Column we are dealing withDbms.canBeIndexed(org.melati.poem.Column)public String givesCapabilitySQL(Integer userTroid, String capabilityExpr)
givesCapabilitySQL in interface DbmsuserTroid - the troid of the User to use in the querycapabilityExpr - the capability troid we needDbms.givesCapabilitySQL(java.lang.Integer, java.lang.String),
MySQL.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 findDbms.caseInsensitiveRegExpSQL(String, String)public String toString()
toString in interface DbmstoString in class ObjectObject.toString()public String getForeignKeyDefinition(String tableName, String fieldName, String targetTableName, String targetTableFieldName, String fixName)
getForeignKeyDefinition 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 IntegrityFixDbms.getForeignKeyDefinition(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)public String getPrimaryKeyDefinition(String fieldName)
getPrimaryKeyDefinition in interface DbmsfieldName - the table Troid column, often id, unquoted{@inheritDoc},
Dbms.getPrimaryKeyDefinition(java.lang.String)public String alterColumnNotNullableSQL(String tableName, Column<?> column)
DbmsalterColumnNotNullableSQL in interface Dbmspublic String selectLimit(String querySelection, int limit)
selectLimit in interface DbmsquerySelection - main body of querylimit - number to limit toDbms.selectLimit(java.lang.String, int)public String booleanTrueExpression(Column<Boolean> booleanColumn)
DbmsbooleanTrueExpression in interface DbmsbooleanColumn - the column which should be a booleanDbms.booleanTrueExpression(org.melati.poem.Column)public 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–2015 PanEris. All rights reserved.