|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectorg.melati.poem.dbms.AnsiStandard
public class AnsiStandard
An SQL 92 compliant Database Management System.
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.
| Field Summary | |
|---|---|
protected String |
schema
|
| Constructor Summary | |
|---|---|
AnsiStandard()
|
|
| Method Summary | |
|---|---|
String |
alterColumnNotNullableSQL(String tableName,
Column column)
Return the SQL snippet to alter a column to not nullable. |
String |
booleanTrueExpression(Column booleanColumn)
Accomodate lack of boolean types. |
boolean |
canBeIndexed(Column column)
MSSQL cannot index a TEXT column. |
boolean |
canDropColumns()
Whether this DBMS can drop columns. |
PoemType<?> |
canRepresent(PoemType<?> storage,
PoemType<?> 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 md)
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)
Accomodate 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. |
protected String |
getDriverClassName()
|
protected boolean |
getDriverLoaded()
|
String |
getFixedPtSqlDefinition(int scale,
int precision)
Accomodate 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()
Accomodate Long / Bigint deviants. |
String |
getPrimaryKeyDefinition(String fieldName)
Return the PRIMARY KEY definition string for this dbms. |
String |
getQuotedName(String name)
Accomodate different quoting strategies. |
String |
getQuotedValue(SQLType sqlType,
String value)
Accomodate 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)
Accomodate String / Text distinction. |
String |
givesCapabilitySQL(Integer userTroid,
String capabilityExpr)
MySQL had no EXISTS keyword, from 4.1 onwards it does. |
protected void |
loadDriver()
|
String |
melatiName(String name)
Reverse the mapping in unreservedName. |
String |
preparedStatementPlaceholder(PoemType<?> type)
Accomodate casting in placeholders. |
String |
selectLimit(String querySelection,
int limit)
Accomodate different limiting syntax. |
protected void |
setDriverClassName(String name)
|
protected void |
setDriverLoaded(boolean loaded)
|
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)
Accomodate 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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected String schema
| Constructor Detail |
|---|
public AnsiStandard()
| Method Detail |
|---|
protected void setDriverClassName(String name)
protected String getDriverClassName()
protected void setDriverLoaded(boolean loaded)
public void unloadDriver()
unloadDriver in interface DbmsDbms.unloadDriver()protected boolean getDriverLoaded()
public String getSchema()
getSchema in interface DbmsDbms.getSchema()
public void shutdown(Connection connection)
throws SQLException
shutdown in interface DbmsSQLExceptionDbms.shutdown(java.sql.Connection)public boolean canDropColumns()
canDropColumns in interface DbmsDbms.canDropColumns()public boolean canStoreBlobs()
canStoreBlobs in interface DbmsDbms.canStoreBlobs()protected void loadDriver()
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 null
ConnectionFailurePoemException - is we cannot connectDbms.getConnection(java.lang.String, java.lang.String, java.lang.String)public String preparedStatementPlaceholder(PoemType<?> type)
preparedStatementPlaceholder in interface DbmsDbms.preparedStatementPlaceholder(org.melati.poem.PoemType)public String createTableSql(Table table)
createTableSql in interface Dbmsorg.melati.poem.dbms.Dbms#createTableSql()public 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 name
Dbms.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 is
SQLExceptionDbms.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 total
SQLException - potentiallyDbms.getFixedPtSqlDefinition(int, int)public String sqlBooleanValueOfRaw(Object raw)
sqlBooleanValueOfRaw in interface DbmsDbms.sqlBooleanValueOfRaw(java.lang.Object)
public PoemType<?> canRepresent(PoemType<?> storage,
PoemType<?> type)
canRepresent in interface Dbmsstorage - the POEM native typetype - the current type
Dbms.canRepresent(org.melati.poem.PoemType, org.melati.poem.PoemType)
public SQLPoemType defaultPoemTypeOfColumnMetaData(ResultSet md)
throws SQLException
defaultPoemTypeOfColumnMetaData in interface Dbmsmd - the JDBC metadata
SQLException - 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 can
Dbms.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 can
Dbms.exceptionForUpdate(org.melati.poem.Table,
java.sql.PreparedStatement,
boolean, java.sql.SQLException)public String getQuotedName(String name)
getQuotedName in interface Dbmsname - the unquoted name
Dbms.getQuotedName(java.lang.String)
public String getQuotedValue(SQLType sqlType,
String value)
getQuotedValue in interface DbmssqlType - the SQLType of the valuevalue - the value
org.melati.poem.dbms.Dbms#getQuotedValue(org.melati.poem.SQLType, java.lang.Object)public String getJdbcMetadataName(String name)
getJdbcMetadataName in interface Dbmsname - entity name such as tableinfo
Dbms.getJdbcMetadataName(java.lang.String)public String unreservedName(String name)
unreservedName in interface Dbmsname - the field or table name
Dbms.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 name
Dbms.melatiName(java.lang.String)public String getIndexLength(Column column)
getIndexLength in interface Dbmscolumn - the POEM Column we are dealing with
Dbms.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 with
Dbms.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 need
Dbms.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 find
Dbms.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 IntegrityFix
Dbms.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)
alterColumnNotNullableSQL in interface DbmsalterColumnNotNullableSQL(java.lang.String, java.lang.String)
public String selectLimit(String querySelection,
int limit)
selectLimit in interface DbmsquerySelection - main body of querylimit - number to limit to
Dbms.selectLimit(java.lang.String, int)public String booleanTrueExpression(Column booleanColumn)
booleanTrueExpression in interface DbmsDbms.booleanTrueExpression(org.melati.poem.Column)public String getSqlDefaultValue(SQLType sqlType)
getSqlDefaultValue in interface DbmssqlType - the type name
org.melati.poem.dbms.Dbms#getSqlDefaultValue(java.lang.String)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||