SRJRCFrames
v0.1.296

de.schwarzrot.data.access.support
Class MyUtils

java.lang.Object
  extended by de.schwarzrot.data.access.support.AbstractDbUtils
      extended by de.schwarzrot.data.access.support.MyUtils
All Implemented Interfaces:
DbUtil

public final class MyUtils
extends AbstractDbUtils

mysql-variant of utility-class to handle physical dependencies to database, like quoting, schema support, ...

Author:
Reinhard Mantey

Field Summary
 
Fields inherited from class de.schwarzrot.data.access.support.AbstractDbUtils
skipList
 
Fields inherited from interface de.schwarzrot.data.access.support.DbUtil
EMPTY_STRING, ONE_SPACE, PK_NAME
 
Constructor Summary
MyUtils()
           
 
Method Summary
 String genAccessRightsFor(TableDefinition ti, String defaultUser)
          generates a SQL-string to grant access rights to tables
protected  String genAutoIncrement(ColumnDefinition cd)
           
 String genDBAccess(DatabaseModel dbInfo, String user)
          generates a SQL-string to grant access rights to the entire database
protected  String genPrimary(TableDefinition ti)
           
 String genUserCreation(String user, String password, String host)
          generates a SQL statement to create a user/role/principal.
protected  String getDBCharset()
           
 String getFieldSeparator()
          returns the separator used in field lists
protected  String getIndexName(IndexDefinition ii)
           
 String getMapped(String dbObjName)
          returns the quoted name of database identifiers (table, column, etc), cause we always want do handle case sensitive identifiers
 String getSchemaSeparator()
          returns the schema separator for the actual storage.
protected  String getTableAttributes(TableDefinition td)
           
 String getTableNameFor(EntityDescriptor ed)
          returns the tablename for given entity
 String getTableNameFor(TableDefinition ti)
          returns the tablename of given table model information
 String getTerminator()
          returns the terminator of SQL statements
protected  String getUsernameFor(String user, String host)
           
 boolean isExistsSupported()
          signals whether current database supports exists on drop tables
 boolean needDropIndexAfterDropTable()
          signals whether an index must be dropped separately after removal of a table
 boolean needExternalSequenceForSerial()
          signals whether the database needs an external sequence to support autoincrement columns
 boolean needSequenceResetAfterTruncate()
          signals whether the database needs to set a new value to the sequence on removing all records of a table
 String quoteAndCutValue(Object value, int size)
          some databases pad strings to an unsupported size, so this call ensures, that the quoted string does not exceed the defined column size.
 boolean supportsGeneratedKeyQuery()
          signals whether the JDBC implementation supports the call for generated (autoincrement) keys.
protected  boolean supportsNativeSchemata()
           
 
Methods inherited from class de.schwarzrot.data.access.support.AbstractDbUtils
columnDefinitions, createColumnDef, dumpRS, genAccessRightsForPK, genColumnCreation, genColumnModification, genCondition, genCondition, genCondition, genDBCreation, genIndexCreation, genIndexRemoval, genInsert, genInsertIdQuery, genOrder, genOrder, genRemove, genSchemaAccess, genSchemaCreation, genSequenceReset, genTableCreation, genTableMetaAccess, genTablePKCreation, genTablePKMod, genTableRemoval, genTableRemoval, genTruncate, genUpdate, genUpdate, genUserCreation, getLogger, getMapped, getTypeFor, getTypeFrom, indexDefinitions, needsUpdate, needsUpdate, schemaDefinitions, tableDefinitions, xpandInsert
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MyUtils

public MyUtils()
Method Detail

genAccessRightsFor

public String genAccessRightsFor(TableDefinition ti,
                                 String defaultUser)
Description copied from interface: DbUtil
generates a SQL-string to grant access rights to tables

Parameters:
ti - - table model information
defaultUser - - the user that gets the rights granted
Returns:
- the ready to use SQL statement

genDBAccess

public String genDBAccess(DatabaseModel dbInfo,
                          String user)
Description copied from interface: DbUtil
generates a SQL-string to grant access rights to the entire database

Parameters:
dbInfo - - database model information
user - - the user that gets the rights granted
Returns:
- the ready to use SQL statement

genUserCreation

public String genUserCreation(String user,
                              String password,
                              String host)
Description copied from interface: DbUtil
generates a SQL statement to create a user/role/principal. Use this call, if the users permissions should be bound to given host

Parameters:
user - - name of the user
password - - password for that user
host - - name of the host
Returns:
- the generated SQL statement

getFieldSeparator

public String getFieldSeparator()
Description copied from interface: DbUtil
returns the separator used in field lists

Returns:
a separator string

getMapped

public String getMapped(String dbObjName)
Description copied from interface: DbUtil
returns the quoted name of database identifiers (table, column, etc), cause we always want do handle case sensitive identifiers

Parameters:
dbObjName - - the identifier to quote
Returns:
- the quoted identifier

getSchemaSeparator

public String getSchemaSeparator()
Description copied from interface: DbUtil
returns the schema separator for the actual storage. Storage systems, that don't support schemata should return an '_' (underscore).

Returns:
- separator used for schema handling

getTableNameFor

public String getTableNameFor(EntityDescriptor ed)
Description copied from interface: DbUtil
returns the tablename for given entity

Parameters:
ed - - descriptor of an entity
Returns:
- a tablename

getTableNameFor

public String getTableNameFor(TableDefinition ti)
Description copied from interface: DbUtil
returns the tablename of given table model information

Parameters:
ti - - table model information
Returns:
- the table name

getTerminator

public String getTerminator()
Description copied from interface: DbUtil
returns the terminator of SQL statements

Returns:
- a SQL statement terminator

isExistsSupported

public final boolean isExistsSupported()
Description copied from class: AbstractDbUtils
signals whether current database supports exists on drop tables

Specified by:
isExistsSupported in class AbstractDbUtils
Returns:
true if conditional drop tables are supported, otherwise false

needDropIndexAfterDropTable

public final boolean needDropIndexAfterDropTable()
Description copied from interface: DbUtil
signals whether an index must be dropped separately after removal of a table

Returns:
true if index must be dropped separately, otherwise false

needExternalSequenceForSerial

public final boolean needExternalSequenceForSerial()
Description copied from interface: DbUtil
signals whether the database needs an external sequence to support autoincrement columns

Returns:
- true if the database needs an external sequence, otherwise false

needSequenceResetAfterTruncate

public final boolean needSequenceResetAfterTruncate()
Description copied from interface: DbUtil
signals whether the database needs to set a new value to the sequence on removing all records of a table

Returns:
- true if the database needs to set a value to the sequence, otherwise false

quoteAndCutValue

public String quoteAndCutValue(Object value,
                               int size)
Description copied from interface: DbUtil
some databases pad strings to an unsupported size, so this call ensures, that the quoted string does not exceed the defined column size.

Parameters:
value - - the value to store
size - - declared field size
Returns:
- the quoted string that fits the field

supportsGeneratedKeyQuery

public boolean supportsGeneratedKeyQuery()
Description copied from interface: DbUtil
signals whether the JDBC implementation supports the call for generated (autoincrement) keys.

Returns:
- true if the JDBC implementation supports the call of generatedKeys, otherwise false

genAutoIncrement

protected String genAutoIncrement(ColumnDefinition cd)
Specified by:
genAutoIncrement in class AbstractDbUtils

genPrimary

protected String genPrimary(TableDefinition ti)
Specified by:
genPrimary in class AbstractDbUtils

getDBCharset

protected String getDBCharset()
Specified by:
getDBCharset in class AbstractDbUtils

getIndexName

protected String getIndexName(IndexDefinition ii)
Specified by:
getIndexName in class AbstractDbUtils

getTableAttributes

protected String getTableAttributes(TableDefinition td)
Specified by:
getTableAttributes in class AbstractDbUtils

getUsernameFor

protected String getUsernameFor(String user,
                                String host)
Specified by:
getUsernameFor in class AbstractDbUtils

supportsNativeSchemata

protected final boolean supportsNativeSchemata()
Specified by:
supportsNativeSchemata in class AbstractDbUtils

SRJRCFrames
v0.1.296

hosted at
Find SRJRCFrames at SourceForge.net. Fast, secure and free:
           Open Source Software download
Submit a bug or request a feature

SRJRCFrames is published according to the GNU General Public License
Copyright 2005-2012 Reinhard Mantey - some rights reserved.