com.sage.orion.sdata.servlet.swtservice.tablebuilder
Class JDBCTableBuilder

java.lang.Object
  extended by com.sage.orion.sdata.servlet.swtservice.tablebuilder.JDBCTableBuilder
All Implemented Interfaces:
DBTableBuilder

public class JDBCTableBuilder
extends java.lang.Object
implements DBTableBuilder

JDBCTableBuilder provides implementation of the DBTableBuilder interface. It includes a set of service functions to create table, add keys, indices. It also populates the table with data from the xml file or a DOM document.


Field Summary
static java.lang.String RECORD_TAG
          Record tag
static java.lang.String RECORDS_TAG
          Records tag
 
Constructor Summary
JDBCTableBuilder(JDBCDatabaseType databaseType)
          Constructor
 
Method Summary
 void addField(java.lang.String name, FieldDataType fieldDataType, int length, boolean allownull, java.lang.String identity, java.lang.String identityStart, java.lang.String identityIncrement)
          Adds field to the collection
 void addFields(java.util.Collection<FieldDefinition> fields)
          Adds fields to table
 void addIndex(java.lang.String index, java.lang.String name)
          Adds index to map
 void addIndices(java.util.Collection<IndexDefinition> indices)
          Adds indices to table
 void addKey(java.lang.String key, boolean isPrimaryKey)
          Sets primary key
 void addRecordsFromDOMDocument(org.w3c.dom.Document document)
          Insert the records into the table from an XML document of suitable format.
 void addRecordsFromXml(java.lang.String xmlFileName)
          Reads records from xml file and adds them to table
 void buildTable(java.sql.Connection connection, java.lang.String name, boolean createTableIfNotExists)
          Creates table
 void closePortalPreparedStatements(java.lang.String tableName)
          Closes the PreparedStatements for populating the portal database.
 java.sql.ResultSet getResultSetFromQuery(java.sql.Statement statement, java.lang.String query)
          get the resultset object from the given Statement and query string.
 boolean isTableExist(java.sql.Connection connection, java.lang.String tableName)
          Check for the given table is exist or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RECORD_TAG

public static final java.lang.String RECORD_TAG
Record tag

See Also:
Constant Field Values

RECORDS_TAG

public static final java.lang.String RECORDS_TAG
Records tag

See Also:
Constant Field Values
Constructor Detail

JDBCTableBuilder

public JDBCTableBuilder(JDBCDatabaseType databaseType)
Constructor

Parameters:
databaseType - the underlying databaseType.
Method Detail

addField

public void addField(java.lang.String name,
                     FieldDataType fieldDataType,
                     int length,
                     boolean allownull,
                     java.lang.String identity,
                     java.lang.String identityStart,
                     java.lang.String identityIncrement)
Adds field to the collection

Specified by:
addField in interface DBTableBuilder
Parameters:
name - - The name of the field
fieldDataType - - The database-agnostic data type of the field
length - - The length of the field
allownull - - The allownull attribute of the field
identity - - The identity of the auto-incremental field
identityStart - - The Start of the auto-incremental field
identityIncrement - - The Increment of the auto-incremental field

addFields

public void addFields(java.util.Collection<FieldDefinition> fields)
Adds fields to table

Specified by:
addFields in interface DBTableBuilder
Parameters:
fields - - collection of field definitions

addKey

public void addKey(java.lang.String key,
                   boolean isPrimaryKey)
Sets primary key

Parameters:
key - - key name
isPrimaryKey - - primary or foreign key flag

addIndex

public void addIndex(java.lang.String index,
                     java.lang.String name)
Adds index to map

Specified by:
addIndex in interface DBTableBuilder
Parameters:
index - - Index identifier
name - - The name argument of the index

addIndices

public void addIndices(java.util.Collection<IndexDefinition> indices)
Adds indices to table

Specified by:
addIndices in interface DBTableBuilder
Parameters:
indices - - collection of index definitions

addRecordsFromDOMDocument

public void addRecordsFromDOMDocument(org.w3c.dom.Document document)
Insert the records into the table from an XML document of suitable format.

Parameters:
document - records as a XML document

addRecordsFromXml

public void addRecordsFromXml(java.lang.String xmlFileName)
Reads records from xml file and adds them to table

Specified by:
addRecordsFromXml in interface DBTableBuilder
Parameters:
xmlFileName - - full path/name of the xml file

buildTable

public void buildTable(java.sql.Connection connection,
                       java.lang.String name,
                       boolean createTableIfNotExists)
Creates table

Parameters:
connection - - connection to the table
name - - table name
createTableIfNotExists - flag

isTableExist

public boolean isTableExist(java.sql.Connection connection,
                            java.lang.String tableName)
Check for the given table is exist or not.

Parameters:
connection - Connection to connect database tables
tableName - String having table name.
Returns:
return true (if Table exists)
false - if Table is not exist

getResultSetFromQuery

public java.sql.ResultSet getResultSetFromQuery(java.sql.Statement statement,
                                                java.lang.String query)
                                         throws java.sql.SQLException
get the resultset object from the given Statement and query string.

Parameters:
statement - statement
query - query
Returns:
result set
Throws:
java.sql.SQLException - exception

closePortalPreparedStatements

public void closePortalPreparedStatements(java.lang.String tableName)
Closes the PreparedStatements for populating the portal database.

Parameters:
tableName - The portal table name.


Copyright © 2011 Sage Software, Inc. All rights reserved.