Class TableDefinition

java.lang.Object
anderix.datajets.TableDefinition

public class TableDefinition extends Object
Contains information about a physical database table. TableDefinition allows a DataJet to contain all the information neccessary to build a corresponding table in which to store its data. When using a TableDefinition object, it is usually neccessary to include information about your database platform that may not be portable to other platforms.
See Also:
  • Constructor Details

    • TableDefinition

      public TableDefinition(String table, String idField, String idFieldProperties)
      Constructor that begins the physical table definition.
      Parameters:
      table - name of the physical database table
      idField - name of the field to use as identity
      idFieldProperties - string that defines the id field
  • Method Details

    • addField

      public void addField(String fieldName, String fieldProperties)
      Adds a field to the table definition.
      Parameters:
      fieldName - name of the field to add
      fieldProperties - string that defines the field
    • getTable

      public String getTable()
      Returns the name of the table.
      Returns:
      name of the table
    • indexOf

      public int indexOf(String fieldName)
      Finds the index of the field specified.
      Parameters:
      fieldName - name of field to find index of
      Returns:
      index of the field; or -1 if not found
    • getFieldName

      public String getFieldName(int fieldIndex)
      Returns the name of the field located at the specified index.
      Parameters:
      fieldIndex - index of field to return
      Returns:
      name of the field
    • getFieldNames

      public String[] getFieldNames()
      Returns the names of all field specified.
      Returns:
      array containing all the names of the fields
    • getFieldProperties

      public String getFieldProperties(int fieldIndex)
      Returns the properties for the field located at the specified index.
      Parameters:
      fieldIndex - index of field to return
      Returns:
      properties of the field
    • getFieldProperties

      public String[] getFieldProperties()
      Returns the properties of all field specified.
      Returns:
      array containing all the properties of the fields
    • createSqlBuilder

      public SqlBuilder createSqlBuilder()
      Creates a SqlBuilder object based on the TableDefinition.
      Returns:
      new SqlBuilder object
    • createTable

      public void createTable(ConnectionGenerator generator, boolean dropTableFirst) throws DataJetException
      Creates a physical database table based on the TableDefinition.
      Parameters:
      generator - ConnectionGenerator with database connection information
      dropTableFirst - set to true to drop existing table before creating table
      Throws:
      DataJetException - if the connection information provided to the DataJet object is incorrect or if the DataJet has not been initialized
    • createTable

      public void createTable(String driver, String connectionString, boolean dropTableFirst) throws DataJetException
      Creates a physical database table based on the TableDefinition.
      Parameters:
      driver - string name of driver class to load
      connectionString - database url to create Connection object
      dropTableFirst - set to true to drop existing table before creating table
      Throws:
      DataJetException - if the connection information provided to the DataJet object is incorrect or if the DataJet has not been initialized
    • createTable

      public void createTable(Connection con, boolean dropTableFirst) throws DataJetException
      Creates a physical database table based on the TableDefinition.
      Parameters:
      con - existing connection to the database server
      dropTableFirst - set to true to drop existing table before creating table
      Throws:
      DataJetException - if the DataJet has not been initialized