org.makumba.db.makumba.sql
Class TableManager

java.lang.Object
  extended by org.makumba.db.makumba.Table
      extended by org.makumba.db.makumba.sql.TableManager
Direct Known Subclasses:
CloudscapeTableManager, DbcpTableManager, HsqldbTableManager, InformixTableManager, MsqlTableManager, MsSqlTableManager, MysqlTableManager, OdbcjetTableManager, OracleTableManager, PgsqlTableManager, QedTableManager

public class TableManager
extends Table


Nested Class Summary
(package private)  class TableManager.CatalogChecker
           
protected static interface TableManager.CheckingStrategy
           
 
Field Summary
(package private)  boolean admin
           
(package private)  boolean alter
           
(package private)  Hashtable<String,String> checkDuplicate
          The query that searches for duplicates on this field
(package private)  Hashtable<String,String> checkNullDuplicate
           
protected  int dbsv
           
(package private)  boolean exists_
           
(package private)  Hashtable<String,String[]> extraIndexes
           
(package private)  Hashtable<String,String[]> foreignKeys
           
(package private)  Hashtable<String,Object> handlerExist
           
protected  String handlerList
           
protected  String handlerListAutoIncrement
           
protected  String indexDBField
           
(package private)  Hashtable<String,Boolean> indexes
           
protected  String indexField
           
(package private)  Dictionary<String,Integer> keyIndex
           
protected  String modTable
           
(package private)  Boolean parsedForeignKeys
           
(package private)  String preparedDeleteFromIgnoreDbsvString
           
(package private)  String preparedDeleteFromString
           
(package private)  String preparedDeleteString
           
(package private)  String preparedInsertAutoIncrementString
           
(package private)  String preparedInsertString
           
protected  long primaryKeyCurrentIndex
           
(package private) static SimpleDateFormat sqlDateFormat
           
protected  String tbname
           
 
Fields inherited from class org.makumba.db.makumba.Table
dd
 
Constructor Summary
TableManager()
           
 
Method Summary
(package private)  boolean alter(SQLDBConnection dbc, String fieldName, String op)
           
protected  void alter(SQLDBConnection dbc, TableManager.CheckingStrategy cs, boolean alter)
          checks if an alteration is needed, and calls doAlter if so
 Object base_getValue(String fieldName, ResultSet rs, int i)
           
 String base_inCreate(String fieldName, Database d)
           
 void base_setInsertArgument(String fieldName, PreparedStatement ps, int n, Dictionary<String,Object> d)
           
 Object base_toSQLObject(String fieldName, Object o)
           
protected  boolean base_unmodified(String fieldName, int type, int size, Vector<Hashtable<String,Object>> columns, int index)
           
 String base_writeConstant(String fieldName, Object o)
           
 boolean canAdmin()
          does the table exist in the database ?
protected  boolean check_char_Width(String fieldName, int width)
          check the char width
protected  boolean check_char_Width(String fieldName, ResultSetMetaData rsm, int index)
          check the char width
 Object check_timeStamp_ValueImpl(String fieldName, Object value)
           
protected  void checkCopy(String fieldName, String s)
           
 boolean checkDuplicate(String[] fields, Object[] values, DBConnection dbc)
          return whether there was a duplicate entry for this multi-field combination when inserting the given data
 boolean checkDuplicate(String fieldName, DBConnection dbc, Dictionary<String,Object> data)
          return whether there was a duplicate for this field when inserting the given data
 void checkInsert(Dictionary<String,Object> fieldsToCheck, Dictionary<String,DataHolder> fieldsToIgnore, Dictionary<String,Object> allFields)
          Checks if a set of values can be inserted in the database
protected  void checkStructure(SQLDBConnection dbc, Properties config)
           
 void checkUpdate(Pointer pointer, Dictionary<String,Object> allFields)
          Checks if a set of values can be updated in the database
 void close()
           
protected  void create(SQLDBConnection dbc, String tblname, boolean really)
          a table creation, from this table's RecordInfo
protected  String createDbSpecific(String command)
          for mysql
 int deleteFrom(DBConnection here, DBConnection source, boolean ignoreDbsv)
          delete all the records created within the indicated database and return their number
 void deleteRecord(DBConnection dbc, Pointer uid)
           
protected  void doAlter(SQLDBConnection dbc, Vector<String> drop, Vector<String> present, Vector<String> add, Vector<String> modify)
          do the needed alterations after examining the data definition of the existing table. a temporary copy table is created, and the fields are copied from it to the re-CREATEd table.
 boolean exists()
          does the table exist in the database ?
 boolean exists(String s)
          does the field exist in the database ?
protected  void fieldList(StringBuffer command, Enumeration<String> e)
          list the given fields in a command field1, field2 ...
protected  void fillResult(ResultSet rs, Dictionary<String,Object> p)
           
protected  void fillResult(ResultSet rs, Object[] data)
           
 void findDuplicates(DBConnection dbc, Dictionary<String,Object> d)
          finds duplicates in the database, given a dictionary of data to insert/update
 boolean findMultiFieldMultiTableDuplicates(Pointer pointer, DataDefinition.MultipleUniqueKeyDefinition definition, Object[] values, SQLDBConnection dbc)
          Checks for potential duplicates for multi-field unique keys that span over more than one data definition.
 String foreignKeyCreateSyntax(String fieldName, String fkTableName, String fkFieldName)
          Syntax for unique index creation.
protected  String get_binary_FieldDBType(String fieldName)
          returns text
protected  int get_binary_SQLType(String fieldName)
           
 Object get_binary_Value(String fieldName, ResultSet rs, int i)
          get the java value of the recordSet column corresponding to this field.
protected  String get_boolean_FieldDBType(String fieldName)
           
protected  int get_boolean_SQLType(String fieldName)
           
 Object get_boolean_Value(String fieldName, ResultSet rs, int i)
           
protected  String get_char_FieldDBType(String fieldName)
          returns char
protected  int get_char_SQLType(String fieldName)
           
 Object get_char_Value(String fieldName, ResultSet rs, int i)
          get the java value of the recordSet column corresponding to this field.
protected  String get_dateTime_FieldDBType(String fieldName)
          returns datetime
 int get_dateTime_SQLType(String fieldName)
           
 Object get_dateTime_Value(String fieldName, ResultSet rs, int i)
          get the java value of the recordSet column corresponding to this field.
protected  String get_int_FieldDBType(String fieldName)
          Use standard SQL name, unless defined otherwise in sqlEngines.properties.
protected  int get_int_SQLType(String fieldName)
           
 Object get_int_Value(String fieldName, ResultSet rs, int i)
           
 Object get_nil_Value(String fieldName, ResultSet rs, int i)
           
protected  String get_ptrDB_FieldDBType(String fieldName)
          returns INT
 int get_ptrDB_SQLType(String fieldName)
           
 Object get_ptrDB_Value(String fieldName, ResultSet rs, int i)
          return the value as a Pointer
protected  String get_real_FieldDBType(String fieldName)
          Use standard SQL name, unless defined otherwise in sqlEngines.properties.
protected  int get_real_SQLType(String fieldName)
           
protected  String get_text_FieldDBType(String fieldName)
          returns text
 Object get_text_Value(String fieldName, ResultSet rs, int i)
          get the java value of the recordSet column corresponding to this field.
protected  String get_timeStamp_FieldDBType(String fieldName)
          returns timestamp
 int get_timeStamp_SQLType(String fieldName)
           
 Object get_timeStamp_Value(String fieldName, ResultSet rs, int i)
           
protected  String getColumnAlterKeyword()
           
protected  String getCreateAutoIncrementSyntax()
           
 String getDBName()
           
protected  String getEngineProperty(String fieldName, String s)
          what is the property of the current engine?
 String getFieldDBIndexName(String fieldName)
          Ask this field how to name the index on this field.
 String getFieldDBName(String fieldName)
          the database-level name of the field
protected  String getFieldDBType(String fieldName)
          what is the database level type of this field?
protected  String getFieldDBType(String fieldName, Database d)
          what is the database level type of this field?
protected  String getQueryAutoIncrementSyntax()
           
protected  Database getSQLDatabase()
           
protected  int getSQLType(String fieldName)
          what is the SQL type of this field?
protected  String getTableMissingStateName(SQLDBConnection dbc)
          mysql needs to have it adjustable
 Object getValue(ResultSet rs, String fieldName, int i)
           
 Object getValue(String fieldName, ResultSet rs, int i)
          get the java value of the recordSet column corresponding to this field.
 boolean hasForeignKey(String fieldName)
           
 String in_boolean_Create(String fieldName, Database d)
          write in CREATE, in the form name BIT(1)
 String in_char_Create(String fieldName, Database d)
          write in CREATE, in the form name char[size]
 String inCondition(String fieldName, Dictionary<String,Object> d, String cond)
          ask this field to write its contribution in a SQL UPDATE statement should return "" if this field doesn't want to take part in the update
 String inCreate(String fieldName, Database d)
          ask this field to write its contribution in a SQL CREATE statement
protected  void indexCreated(SQLDBConnection dbc)
          for odbc
 String indexCreateSyntax(String fieldName)
          Syntax for index creation.
 String indexCreateUniqueSyntax(String fieldName)
          Syntax for unique index creation.
 String indexCreateUniqueSyntax(String[] fieldNames)
          Syntax for multi-field index
 String indexDropSyntax(String fieldName)
          Syntax for dropping index.
protected  void initFields(SQLDBConnection dbc, Properties config)
           
 String inPreparedInsert(String fieldName)
          ask this field to write write its argument placeholder ('?')
 String inPreparedUpdate(String fieldName)
          ask this field to write its argument placeholder in a prepared UPDATE SQL statement
 Pointer insertRecordImpl(DBConnection dbc, Dictionary<String,Object> d)
           
 boolean isIndexOk(String fieldName)
          Examine DB indexes.
 boolean isIndexOk(String[] fieldNames)
           
(package private)  void makeKeyIndex()
           
 void manageForeignKeys(String fieldName, SQLDBConnection dbc, String brief)
           
 void manageIndexes(String fieldName, SQLDBConnection dbc)
          Ask this field to add/remove indexes as needed, normally called from onStartup().
protected  long nextId_ptrIndex()
          determines the unique index by incrementing a counter
 SQLPointer nxt_ptrIndex(String fieldName, Dictionary<String,Object> d)
           
(package private)  void nxt(String fieldName, Dictionary<String,Object> d)
           
 void onStartup(String fieldName, Properties config, SQLDBConnection dbc)
          ask this field to perform actions when the table is open
protected  void open(Properties config, NameResolver nr)
          the SQL table opening. might call create() or alter()
protected  String prepareDelete()
           
protected  String prepareInsert(boolean autoIncrement)
           
protected  void resetPrimaryKey()
           
 void set_binary_Argument(String fieldName, PreparedStatement ps, int n, Object o)
           
 void set_text_Argument(String fieldName, PreparedStatement ps, int n, Object o)
           
 void set_timeStamp_InsertArgument(String fieldName, PreparedStatement ps, int n, Dictionary<String,Object> d)
           
 void setArgument(String fieldName, PreparedStatement ps, int n, Object o)
          set a non-null argument of this type in a prepared SQL statement
 void setCopyArgument(String fieldName, PreparedStatement ps, int n, Dictionary<String,Object> d)
          ask this field to write write its argument value in a prepared SQL statement for copying
 void setInsertArgument(String fieldName, PreparedStatement ps, int n, Dictionary<String,Object> d)
          ask this field to write write its argumment value in a prepared INSERT SQL statement
 void setNullArgument(String fieldName, PreparedStatement ps, int n)
          set a null argument of this type in a prepared SQL statement
protected  void setTableAndFieldNames(NameResolver nr)
          the SQL table opening. might call create() or alter()
 void setUpdateArgument(String fieldName, PreparedStatement ps, int n, Dictionary<String,Object> d)
          ask this field to write write its argumment value in a prepared UPDATE SQL statement
 void setUpdateArgument(String fieldName, PreparedStatement ps, int n, Object o)
          ask this field to write write its argument value in a prepared UPDATE SQL statement
 void setValue(String fieldName, Dictionary<String,Object> d, ResultSet rs, int i)
          set the java value in a data chunk.
 void setValue(String fieldName, Object[] data, ResultSet rs, int i)
          set the java value in a data chunk.
 boolean should_text_Index(String fieldName)
           
 boolean shouldIndex(String fieldName)
          Tell whether this type of field should be indexed.
 Object toSQL_dateTime_Object(String fieldName, Object o)
           
 Object toSQL_ptrDB_Object(String fieldName, Object o)
          ask this field to write a value of its type in a SQL statement
 Object toSQLObject(String fieldName, Object o)
          transform the object for a SQL insert or update
protected  boolean unmodified_char(String fieldName, int type, int size, Vector<Hashtable<String,Object>> columns, int index)
          Checks if the type is java.sql.Types.CHAR.
protected  boolean unmodified_wrapper(String fieldName, int type, int size, Vector<Hashtable<String,Object>> v, int index)
          check if the column from the SQL database still coresponds with the abstract definition of this field
protected  boolean unmodified(String fieldName, int type, int size, Vector<Hashtable<String,Object>> columns, int index)
          check if the column from the SQL database (read from the catalog) still corresponds with the abstract definition of this field
 void updateRecord(DBConnection dbc, Pointer uid, Dictionary<String,Object> d)
          Deprecated. 
protected  boolean usesHidden()
           
 String write_binary_Constant(String fieldName, Object o)
          does apostrophe escape
 String write_boolean_Constant(String fieldName, Object o)
           
 String write_char_Constant(String fieldName, Object o)
          does apostrophe escape
 String write_dateTime_Constant(String fieldName, Object o)
          writes the date between apostrophes
 String write_text_Constant(String fieldName, Object o)
          does apostrophe escape
 String write_timeStamp_Constant(String fieldName, Object o)
          writes the date between apostrophes
 String writeConstant(String fieldName, Object o)
          ask this field to write a value of its type in a SQL statement
 
Methods inherited from class org.makumba.db.makumba.Table
getDatabase, getDataDefinition, getFieldDefinition, getRelatedTable, insertRecord, setDataDefinition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tbname

protected String tbname

handlerList

protected String handlerList

handlerListAutoIncrement

protected String handlerListAutoIncrement

indexDBField

protected String indexDBField

indexField

protected String indexField

modTable

protected String modTable

primaryKeyCurrentIndex

protected long primaryKeyCurrentIndex

dbsv

protected int dbsv

alter

boolean alter

exists_

boolean exists_

handlerExist

Hashtable<String,Object> handlerExist

keyIndex

Dictionary<String,Integer> keyIndex

preparedInsertString

String preparedInsertString

preparedInsertAutoIncrementString

String preparedInsertAutoIncrementString

preparedDeleteString

String preparedDeleteString

preparedDeleteFromString

String preparedDeleteFromString

preparedDeleteFromIgnoreDbsvString

String preparedDeleteFromIgnoreDbsvString

checkDuplicate

Hashtable<String,String> checkDuplicate
The query that searches for duplicates on this field


checkNullDuplicate

Hashtable<String,String> checkNullDuplicate

admin

boolean admin

indexes

Hashtable<String,Boolean> indexes

parsedForeignKeys

Boolean parsedForeignKeys

foreignKeys

Hashtable<String,String[]> foreignKeys

extraIndexes

Hashtable<String,String[]> extraIndexes

sqlDateFormat

static SimpleDateFormat sqlDateFormat
Constructor Detail

TableManager

public TableManager()
Method Detail

exists

public boolean exists()
Description copied from class: Table
does the table exist in the database ?

Specified by:
exists in class Table

exists

public boolean exists(String s)
Description copied from class: Table
does the field exist in the database ?

Specified by:
exists in class Table

getDBName

public String getDBName()

getSQLDatabase

protected Database getSQLDatabase()

usesHidden

protected boolean usesHidden()

makeKeyIndex

void makeKeyIndex()

open

protected void open(Properties config,
                    NameResolver nr)
the SQL table opening. might call create() or alter()

Specified by:
open in class Table

close

public void close()
Specified by:
close in class Table

setTableAndFieldNames

protected void setTableAndFieldNames(NameResolver nr)
the SQL table opening. might call create() or alter()


canAdmin

public boolean canAdmin()
Description copied from class: Table
does the table exist in the database ?

Specified by:
canAdmin in class Table

checkStructure

protected void checkStructure(SQLDBConnection dbc,
                              Properties config)

initFields

protected void initFields(SQLDBConnection dbc,
                          Properties config)
                   throws SQLException
Throws:
SQLException

deleteFrom

public int deleteFrom(DBConnection here,
                      DBConnection source,
                      boolean ignoreDbsv)
Description copied from class: Table
delete all the records created within the indicated database and return their number

Specified by:
deleteFrom in class Table

alter

protected void alter(SQLDBConnection dbc,
                     TableManager.CheckingStrategy cs,
                     boolean alter)
              throws SQLException
checks if an alteration is needed, and calls doAlter if so

Parameters:
alter - TODO
Throws:
SQLException

getColumnAlterKeyword

protected String getColumnAlterKeyword()

alter

boolean alter(SQLDBConnection dbc,
              String fieldName,
              String op)
        throws SQLException
Throws:
SQLException

doAlter

protected void doAlter(SQLDBConnection dbc,
                       Vector<String> drop,
                       Vector<String> present,
                       Vector<String> add,
                       Vector<String> modify)
                throws SQLException
do the needed alterations after examining the data definition of the existing table. a temporary copy table is created, and the fields are copied from it to the re-CREATEd table. ALTER TABLE might be used instead, and drivers that don't support it will have their own RecordManager, extending this one.

Parameters:
drop - the names of the db fields that should be dropped (they might not be)
present - the abstract fields that exist in the DB, in DB order
add - the abstract fields that are not present in the db and need to be added
modify - the abstract fields that exist in the db but need to be modified to the new abstract definition
Throws:
SQLException

create

protected void create(SQLDBConnection dbc,
                      String tblname,
                      boolean really)
               throws SQLException
a table creation, from this table's RecordInfo

Throws:
SQLException

fieldList

protected void fieldList(StringBuffer command,
                         Enumeration<String> e)
list the given fields in a command field1, field2 ...


prepareInsert

protected String prepareInsert(boolean autoIncrement)

insertRecordImpl

public Pointer insertRecordImpl(DBConnection dbc,
                                Dictionary<String,Object> d)
Specified by:
insertRecordImpl in class Table

findDuplicates

public void findDuplicates(DBConnection dbc,
                           Dictionary<String,Object> d)
Description copied from class: Table
finds duplicates in the database, given a dictionary of data to insert/update

Specified by:
findDuplicates in class Table

prepareDelete

protected String prepareDelete()

deleteRecord

public void deleteRecord(DBConnection dbc,
                         Pointer uid)

updateRecord

@Deprecated
public void updateRecord(DBConnection dbc,
                                    Pointer uid,
                                    Dictionary<String,Object> d)
Deprecated. 


fillResult

protected void fillResult(ResultSet rs,
                          Dictionary<String,Object> p)
                   throws SQLException
Throws:
SQLException

fillResult

protected void fillResult(ResultSet rs,
                          Object[] data)
                   throws SQLException
Throws:
SQLException

getValue

public Object getValue(ResultSet rs,
                       String fieldName,
                       int i)

getValue

public Object getValue(String fieldName,
                       ResultSet rs,
                       int i)
                throws SQLException
get the java value of the recordSet column corresponding to this field. This method should return null if the SQL field is null

Throws:
SQLException

base_getValue

public Object base_getValue(String fieldName,
                            ResultSet rs,
                            int i)
                     throws SQLException
Throws:
SQLException

get_ptrDB_Value

public Object get_ptrDB_Value(String fieldName,
                              ResultSet rs,
                              int i)
                       throws SQLException
return the value as a Pointer

Throws:
SQLException

get_int_Value

public Object get_int_Value(String fieldName,
                            ResultSet rs,
                            int i)
                     throws SQLException
Throws:
SQLException

get_char_Value

public Object get_char_Value(String fieldName,
                             ResultSet rs,
                             int i)
                      throws SQLException
get the java value of the recordSet column corresponding to this field. This method should return null if the SQL field is null

Throws:
SQLException

get_text_Value

public Object get_text_Value(String fieldName,
                             ResultSet rs,
                             int i)
                      throws SQLException
get the java value of the recordSet column corresponding to this field. This method should return null if the SQL field is null

Throws:
SQLException

get_binary_Value

public Object get_binary_Value(String fieldName,
                               ResultSet rs,
                               int i)
                        throws SQLException
get the java value of the recordSet column corresponding to this field. This method should return null if the SQL field is null

Throws:
SQLException

get_boolean_Value

public Object get_boolean_Value(String fieldName,
                                ResultSet rs,
                                int i)
                         throws SQLException
Throws:
SQLException

get_dateTime_Value

public Object get_dateTime_Value(String fieldName,
                                 ResultSet rs,
                                 int i)
                          throws SQLException
get the java value of the recordSet column corresponding to this field. This method should return null if the SQL field is null

Throws:
SQLException

get_nil_Value

public Object get_nil_Value(String fieldName,
                            ResultSet rs,
                            int i)

get_timeStamp_Value

public Object get_timeStamp_Value(String fieldName,
                                  ResultSet rs,
                                  int i)
                           throws SQLException
Throws:
SQLException

setUpdateArgument

public void setUpdateArgument(String fieldName,
                              PreparedStatement ps,
                              int n,
                              Object o)
                       throws SQLException
ask this field to write write its argument value in a prepared UPDATE SQL statement

Throws:
SQLException

setUpdateArgument

public void setUpdateArgument(String fieldName,
                              PreparedStatement ps,
                              int n,
                              Dictionary<String,Object> d)
                       throws SQLException
ask this field to write write its argumment value in a prepared UPDATE SQL statement

Throws:
SQLException

setNullArgument

public void setNullArgument(String fieldName,
                            PreparedStatement ps,
                            int n)
                     throws SQLException
set a null argument of this type in a prepared SQL statement

Throws:
SQLException

setArgument

public void setArgument(String fieldName,
                        PreparedStatement ps,
                        int n,
                        Object o)
                 throws SQLException
set a non-null argument of this type in a prepared SQL statement

Throws:
SQLException

set_binary_Argument

public void set_binary_Argument(String fieldName,
                                PreparedStatement ps,
                                int n,
                                Object o)
                         throws SQLException
Throws:
SQLException

set_text_Argument

public void set_text_Argument(String fieldName,
                              PreparedStatement ps,
                              int n,
                              Object o)
                       throws SQLException
Throws:
SQLException

getSQLType

protected int getSQLType(String fieldName)
what is the SQL type of this field?


get_ptrDB_SQLType

public int get_ptrDB_SQLType(String fieldName)

get_int_SQLType

protected int get_int_SQLType(String fieldName)

get_char_SQLType

protected int get_char_SQLType(String fieldName)

get_binary_SQLType

protected int get_binary_SQLType(String fieldName)

get_boolean_SQLType

protected int get_boolean_SQLType(String fieldName)

get_dateTime_SQLType

public int get_dateTime_SQLType(String fieldName)

get_real_SQLType

protected int get_real_SQLType(String fieldName)

get_timeStamp_SQLType

public int get_timeStamp_SQLType(String fieldName)

toSQLObject

public Object toSQLObject(String fieldName,
                          Object o)
transform the object for a SQL insert or update


base_toSQLObject

public Object base_toSQLObject(String fieldName,
                               Object o)

toSQL_ptrDB_Object

public Object toSQL_ptrDB_Object(String fieldName,
                                 Object o)
ask this field to write a value of its type in a SQL statement


toSQL_dateTime_Object

public Object toSQL_dateTime_Object(String fieldName,
                                    Object o)

getFieldDBName

public String getFieldDBName(String fieldName)
the database-level name of the field


inCreate

public String inCreate(String fieldName,
                       Database d)
ask this field to write its contribution in a SQL CREATE statement


base_inCreate

public String base_inCreate(String fieldName,
                            Database d)

in_char_Create

public String in_char_Create(String fieldName,
                             Database d)
write in CREATE, in the form name char[size]


in_boolean_Create

public String in_boolean_Create(String fieldName,
                                Database d)
write in CREATE, in the form name BIT(1)


inPreparedUpdate

public String inPreparedUpdate(String fieldName)
ask this field to write its argument placeholder in a prepared UPDATE SQL statement


getFieldDBType

protected String getFieldDBType(String fieldName)
what is the database level type of this field?


get_ptrDB_FieldDBType

protected String get_ptrDB_FieldDBType(String fieldName)
returns INT


get_int_FieldDBType

protected String get_int_FieldDBType(String fieldName)
Use standard SQL name, unless defined otherwise in sqlEngines.properties.


get_char_FieldDBType

protected String get_char_FieldDBType(String fieldName)
returns char


get_text_FieldDBType

protected String get_text_FieldDBType(String fieldName)
returns text


get_binary_FieldDBType

protected String get_binary_FieldDBType(String fieldName)
returns text


get_boolean_FieldDBType

protected String get_boolean_FieldDBType(String fieldName)

get_dateTime_FieldDBType

protected String get_dateTime_FieldDBType(String fieldName)
returns datetime


get_real_FieldDBType

protected String get_real_FieldDBType(String fieldName)
Use standard SQL name, unless defined otherwise in sqlEngines.properties.


get_timeStamp_FieldDBType

protected String get_timeStamp_FieldDBType(String fieldName)
returns timestamp


getFieldDBType

protected String getFieldDBType(String fieldName,
                                Database d)
what is the database level type of this field?


getFieldDBIndexName

public String getFieldDBIndexName(String fieldName)
Ask this field how to name the index on this field. Normally called from manageIndexes().


inPreparedInsert

public String inPreparedInsert(String fieldName)
ask this field to write write its argument placeholder ('?') in a prepared INSERT SQL statement


setInsertArgument

public void setInsertArgument(String fieldName,
                              PreparedStatement ps,
                              int n,
                              Dictionary<String,Object> d)
                       throws SQLException
ask this field to write write its argumment value in a prepared INSERT SQL statement

Throws:
SQLException

base_setInsertArgument

public void base_setInsertArgument(String fieldName,
                                   PreparedStatement ps,
                                   int n,
                                   Dictionary<String,Object> d)
                            throws SQLException
Throws:
SQLException

set_timeStamp_InsertArgument

public void set_timeStamp_InsertArgument(String fieldName,
                                         PreparedStatement ps,
                                         int n,
                                         Dictionary<String,Object> d)
                                  throws SQLException
Throws:
SQLException

setCopyArgument

public void setCopyArgument(String fieldName,
                            PreparedStatement ps,
                            int n,
                            Dictionary<String,Object> d)
                     throws SQLException
ask this field to write write its argument value in a prepared SQL statement for copying

Throws:
SQLException

inCondition

public String inCondition(String fieldName,
                          Dictionary<String,Object> d,
                          String cond)
ask this field to write its contribution in a SQL UPDATE statement should return "" if this field doesn't want to take part in the update


writeConstant

public String writeConstant(String fieldName,
                            Object o)
ask this field to write a value of its type in a SQL statement


base_writeConstant

public String base_writeConstant(String fieldName,
                                 Object o)

write_char_Constant

public String write_char_Constant(String fieldName,
                                  Object o)
does apostrophe escape


write_text_Constant

public String write_text_Constant(String fieldName,
                                  Object o)
does apostrophe escape


write_binary_Constant

public String write_binary_Constant(String fieldName,
                                    Object o)
does apostrophe escape


write_boolean_Constant

public String write_boolean_Constant(String fieldName,
                                     Object o)

write_dateTime_Constant

public String write_dateTime_Constant(String fieldName,
                                      Object o)
writes the date between apostrophes


write_timeStamp_Constant

public String write_timeStamp_Constant(String fieldName,
                                       Object o)
writes the date between apostrophes


getEngineProperty

protected String getEngineProperty(String fieldName,
                                   String s)
what is the property of the current engine?


onStartup

public void onStartup(String fieldName,
                      Properties config,
                      SQLDBConnection dbc)
               throws SQLException
ask this field to perform actions when the table is open

Throws:
SQLException

shouldIndex

public boolean shouldIndex(String fieldName)
Tell whether this type of field should be indexed.


should_text_Index

public boolean should_text_Index(String fieldName)

isIndexOk

public boolean isIndexOk(String fieldName)
Examine DB indexes.


hasForeignKey

public boolean hasForeignKey(String fieldName)

isIndexOk

public boolean isIndexOk(String[] fieldNames)

manageIndexes

public void manageIndexes(String fieldName,
                          SQLDBConnection dbc)
                   throws SQLException
Ask this field to add/remove indexes as needed, normally called from onStartup().

Throws:
SQLException

manageForeignKeys

public void manageForeignKeys(String fieldName,
                              SQLDBConnection dbc,
                              String brief)
                       throws DBError
Throws:
DBError

indexCreateSyntax

public String indexCreateSyntax(String fieldName)
Syntax for index creation.


indexCreateUniqueSyntax

public String indexCreateUniqueSyntax(String fieldName)
Syntax for unique index creation.


foreignKeyCreateSyntax

public String foreignKeyCreateSyntax(String fieldName,
                                     String fkTableName,
                                     String fkFieldName)
Syntax for unique index creation.


indexCreateUniqueSyntax

public String indexCreateUniqueSyntax(String[] fieldNames)
Syntax for multi-field index


indexDropSyntax

public String indexDropSyntax(String fieldName)
Syntax for dropping index.


setValue

public void setValue(String fieldName,
                     Dictionary<String,Object> d,
                     ResultSet rs,
                     int i)
              throws SQLException
set the java value in a data chunk. If the value in the recordset is SQL null, a NullPointerException is thrown

Throws:
SQLException

setValue

public void setValue(String fieldName,
                     Object[] data,
                     ResultSet rs,
                     int i)
              throws SQLException
set the java value in a data chunk. If the value in the recordset is SQL null, a NullPointerException is thrown

Throws:
SQLException

checkCopy

protected void checkCopy(String fieldName,
                         String s)

checkDuplicate

public boolean checkDuplicate(String fieldName,
                              DBConnection dbc,
                              Dictionary<String,Object> data)
return whether there was a duplicate for this field when inserting the given data


checkDuplicate

public boolean checkDuplicate(String[] fields,
                              Object[] values,
                              DBConnection dbc)
return whether there was a duplicate entry for this multi-field combination when inserting the given data


findMultiFieldMultiTableDuplicates

public boolean findMultiFieldMultiTableDuplicates(Pointer pointer,
                                                  DataDefinition.MultipleUniqueKeyDefinition definition,
                                                  Object[] values,
                                                  SQLDBConnection dbc)
Checks for potential duplicates for multi-field unique keys that span over more than one data definition. There is no equivalent for this on the database level, so we need to check this before we insert, in checkInsert(Dictionary, Dictionary, Dictionary).

Returns:
true if an entry for the given key already exists with these values

unmodified

protected boolean unmodified(String fieldName,
                             int type,
                             int size,
                             Vector<Hashtable<String,Object>> columns,
                             int index)
                      throws SQLException
check if the column from the SQL database (read from the catalog) still corresponds with the abstract definition of this field

Throws:
SQLException

base_unmodified

protected boolean base_unmodified(String fieldName,
                                  int type,
                                  int size,
                                  Vector<Hashtable<String,Object>> columns,
                                  int index)
                           throws SQLException
Throws:
SQLException

unmodified_char

protected boolean unmodified_char(String fieldName,
                                  int type,
                                  int size,
                                  Vector<Hashtable<String,Object>> columns,
                                  int index)
                           throws SQLException
Checks if the type is java.sql.Types.CHAR. Then, if the size of the SQL column is still large enough, this returns true. Some SQL drivers allocate more anyway.

Throws:
SQLException

unmodified_wrapper

protected boolean unmodified_wrapper(String fieldName,
                                     int type,
                                     int size,
                                     Vector<Hashtable<String,Object>> v,
                                     int index)
                              throws SQLException
check if the column from the SQL database still coresponds with the abstract definition of this field

Throws:
SQLException

check_char_Width

protected boolean check_char_Width(String fieldName,
                                   ResultSetMetaData rsm,
                                   int index)
                            throws SQLException
check the char width

Throws:
SQLException

check_char_Width

protected boolean check_char_Width(String fieldName,
                                   int width)
                            throws SQLException
check the char width

Throws:
SQLException

resetPrimaryKey

protected void resetPrimaryKey()

nxt

void nxt(String fieldName,
         Dictionary<String,Object> d)

nxt_ptrIndex

public SQLPointer nxt_ptrIndex(String fieldName,
                               Dictionary<String,Object> d)

nextId_ptrIndex

protected long nextId_ptrIndex()
determines the unique index by incrementing a counter


checkInsert

public void checkInsert(Dictionary<String,Object> fieldsToCheck,
                        Dictionary<String,DataHolder> fieldsToIgnore,
                        Dictionary<String,Object> allFields)
Checks if a set of values can be inserted in the database

Specified by:
checkInsert in class Table
Parameters:
fieldsToCheck - the values to be checked
fieldsToIgnore - the values of toCheck not to be checked
allFields - the entire data to be inserted

checkUpdate

public void checkUpdate(Pointer pointer,
                        Dictionary<String,Object> allFields)
Checks if a set of values can be updated in the database

Specified by:
checkUpdate in class Table
Parameters:
pointer - the pointer to the record to be updated
fieldsToCheck - the values to be checked
fieldsToIgnore - the values of toCheck not to be checked
allFields - the entire data to be inserted

check_timeStamp_ValueImpl

public Object check_timeStamp_ValueImpl(String fieldName,
                                        Object value)

indexCreated

protected void indexCreated(SQLDBConnection dbc)
for odbc


createDbSpecific

protected String createDbSpecific(String command)
for mysql


getTableMissingStateName

protected String getTableMissingStateName(SQLDBConnection dbc)
mysql needs to have it adjustable


getQueryAutoIncrementSyntax

protected String getQueryAutoIncrementSyntax()

getCreateAutoIncrementSyntax

protected String getCreateAutoIncrementSyntax()