org.rimudb.sql
Class MySQLAdapter

java.lang.Object
  extended by org.rimudb.sql.DefaultAdapter
      extended by org.rimudb.sql.MySQLAdapter
All Implemented Interfaces:
ISQLAdapter

public class MySQLAdapter
extends DefaultAdapter

This class converts to MySQL types


Field Summary
 
Fields inherited from class org.rimudb.sql.DefaultAdapter
DB_H2, DB_HSQLDB, DB_ISERIES, DB_MYSQL, DB_SQLSERVER, DB_UNKNOWN, IDX_INDEX, IDX_PRIMARY, IDX_UNIQUE, LOCK_DELETE, LOCK_INSERT, LOCK_NONE, LOCK_SELECT, LOCK_UPDATE
 
Fields inherited from interface org.rimudb.sql.ISQLAdapter
IDENTITY_GENERATED_KEYS, IDENTITY_INSERT_STMT, IDENTITY_SEPARATE_STATEMENT
 
Constructor Summary
MySQLAdapter()
           
 
Method Summary
 java.lang.String convertAutoIncrement(boolean autoIncrement)
          Return the String used for auto increment columns
 java.lang.String convertSQLType(int type, long size, int decimals)
          Convert the SQL type to a type that the database can handle.
 void correctRecordData(TableMetaData tableMetaData, Record record)
          Correct data in records that cannot be written to MySQL.
 char getCloseQuote()
          Return the database close quote character.
 java.lang.String getCreateIfExistsClause()
          Return the If Exists clause for a create table statement
 java.lang.String getDropIfExistsClause()
          Return the clause for "drop if exists".
 java.lang.String getEndLimitClause(int maxRecords, int offset)
          Returns a clause for a select statement that limits the number of records returned to the first n records.
 char getOpenQuote()
          Return the database open quote character.
 boolean getSupportsMultipleGetGeneratedKeys()
          Return true if this database supports returning a multiple row result set of generated keys
 boolean getSupportsReturnGeneratedKeys()
          Return true if the database supports the use of prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); If it doesn't then the method prepareStatement(sql, identityColumns[]); will be used.
 java.lang.String getTableType()
          Return the table type
 boolean hasPrimaryKeyClause()
          Return true if the Create Table statement should have a PRIMARY KEY clause
 
Methods inherited from class org.rimudb.sql.DefaultAdapter
build, build, buildGroupByClause, buildOrderByClause, buildSelectClause, buildSQL, buildSQL, buildSQL, buildWhereClause, convertNullCapable, getBeginLimitClause, getCreateTableSQL, getDatabaseConfiguration, getDatabaseMetaData, getDatabaseNames, getDeleteStatement, getDropTableSQL, getIdentitySelectSQL, getInsertStatement, getLockingHint, getPrimaryKeySelectStatement, getPrimaryKeyUpdateStatement, getQuoter, getSelectAllSQL, getSelectCountSQL, getTruncateTableSQL, isInsertIndentityStatementSupported, setDatabaseConfiguration, setDatabaseMetaData, setUseQuotes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySQLAdapter

public MySQLAdapter()
Method Detail

convertSQLType

public java.lang.String convertSQLType(int type,
                                       long size,
                                       int decimals)
Description copied from interface: ISQLAdapter
Convert the SQL type to a type that the database can handle.

Specified by:
convertSQLType in interface ISQLAdapter
Overrides:
convertSQLType in class DefaultAdapter
Parameters:
type - int
size - long
decimals - int
Returns:
String

getEndLimitClause

public java.lang.String getEndLimitClause(int maxRecords,
                                          int offset)
Returns a clause for a select statement that limits the number of records returned to the first n records.

Parameters:
maxRecords - int
offset - int
Returns:
String

hasPrimaryKeyClause

public boolean hasPrimaryKeyClause()
Return true if the Create Table statement should have a PRIMARY KEY clause

Specified by:
hasPrimaryKeyClause in interface ISQLAdapter
Overrides:
hasPrimaryKeyClause in class DefaultAdapter
Returns:
boolean

getTableType

public java.lang.String getTableType()
Return the table type

Specified by:
getTableType in interface ISQLAdapter
Overrides:
getTableType in class DefaultAdapter
Returns:
String

convertAutoIncrement

public java.lang.String convertAutoIncrement(boolean autoIncrement)
Return the String used for auto increment columns

Parameters:
autoIncrement - boolean
Returns:
String

getCreateIfExistsClause

public java.lang.String getCreateIfExistsClause()
Description copied from interface: ISQLAdapter
Return the If Exists clause for a create table statement

Specified by:
getCreateIfExistsClause in interface ISQLAdapter
Specified by:
getCreateIfExistsClause in class DefaultAdapter
Returns:
String

getDropIfExistsClause

public java.lang.String getDropIfExistsClause()
Description copied from interface: ISQLAdapter
Return the clause for "drop if exists".

Specified by:
getDropIfExistsClause in interface ISQLAdapter
Specified by:
getDropIfExistsClause in class DefaultAdapter
Returns:
String

getOpenQuote

public char getOpenQuote()
Description copied from interface: ISQLAdapter
Return the database open quote character.

Specified by:
getOpenQuote in interface ISQLAdapter
Overrides:
getOpenQuote in class DefaultAdapter
Returns:
char

getCloseQuote

public char getCloseQuote()
Description copied from interface: ISQLAdapter
Return the database close quote character.

Specified by:
getCloseQuote in interface ISQLAdapter
Overrides:
getCloseQuote in class DefaultAdapter
Returns:
char

getSupportsReturnGeneratedKeys

public boolean getSupportsReturnGeneratedKeys()
Description copied from interface: ISQLAdapter
Return true if the database supports the use of prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); If it doesn't then the method prepareStatement(sql, identityColumns[]); will be used.

Returns:
boolean

getSupportsMultipleGetGeneratedKeys

public boolean getSupportsMultipleGetGeneratedKeys()
Description copied from interface: ISQLAdapter
Return true if this database supports returning a multiple row result set of generated keys

Returns:
boolean

correctRecordData

public void correctRecordData(TableMetaData tableMetaData,
                              Record record)
                       throws RimuDBException
Correct data in records that cannot be written to MySQL.

Specified by:
correctRecordData in interface ISQLAdapter
Overrides:
correctRecordData in class DefaultAdapter
Parameters:
tableMetaData - TableMetaData
record - Record
Throws:
RimuDBException


Copyright © 2008-2011 Simon Ritchie. All Rights Reserved.