com.syncsoft.plainsql
Class PlainTable

java.lang.Object
  extended by com.syncsoft.plainsql.PlainSql
      extended by com.syncsoft.plainsql.PlainTable

public class PlainTable
extends PlainSql

This class represents a single table. Sort of a very weak ORM capability that doesn't need mapping our config (or a competent java programmer to create it :-) ) It's really a PlainSql object that represents a SELECT * FROM table. There are some methods to support DML and it holds table meta data ALL rows will be fetched into memory at some point if you try to access any of rows


Constructor Summary
PlainTable(PSconnection conn, java.lang.String tablename)
          Create a Plain Table object
PlainTable(PSconnection conn, java.lang.String tablename, java.lang.String additionalSQL)
          Create a Plain Table object
 
Method Summary
 int colcount()
          Number of columns in the table
 Row emptyrow()
          Empty row suitable for inserting.
 RowSet emptyRowSet()
           
 RowSet fetchAll()
           
 java.lang.String getColumnList()
           
 java.util.ArrayList<java.lang.String> getColumnNames()
           
 java.util.ArrayList<java.lang.String> getPrimaryKeys()
           
 java.lang.String getTableCatalog()
           
 java.lang.String getTableName()
          Access the name of the table for which this object was created.
 java.lang.String getTablenameSupplied()
           
 java.lang.String getTableSchema()
           
 java.lang.String getTableType()
           
 int insertArray(RowSet rows)
          Insert a batch (array) of rows
 int updateRow(Row updateRow)
          Apply row changes to the database.
 
Methods inherited from class com.syncsoft.plainsql.PlainSql
bindArgs, close, execute, execute, executeBatch, executeUpdate, executeUpdate, fetchAll, fetchOne, getColNames, getFetchahead, getJdbcConnection, getJdbcStatement, getPsConnection, getResult, getRsMetaData, getSql, makeRow, nextRow, setFetchAhead
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlainTable

public PlainTable(PSconnection conn,
                  java.lang.String tablename)
           throws java.sql.SQLException
Create a Plain Table object

Parameters:
conn - PSconnection object
tablename - table name
Throws:
java.sql.SQLException

PlainTable

public PlainTable(PSconnection conn,
                  java.lang.String tablename,
                  java.lang.String additionalSQL)
           throws java.sql.SQLException
Create a Plain Table object

Parameters:
conn - PSconnection object
tablename - table name
additionalSQL - any additional SQL (usually a WHERE clause)
Throws:
java.sql.SQLException
Method Detail

colcount

public int colcount()
             throws java.sql.SQLException
Number of columns in the table

Overrides:
colcount in class PlainSql
Returns:
number of columns
Throws:
java.sql.SQLException

emptyrow

public Row emptyrow()
             throws java.sql.SQLException
Empty row suitable for inserting.

Returns:
A empty Row object
Throws:
java.sql.SQLException

emptyRowSet

public RowSet emptyRowSet()
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

fetchAll

public RowSet fetchAll()
                throws java.sql.SQLException
Throws:
java.sql.SQLException

getColumnList

public java.lang.String getColumnList()

getColumnNames

public java.util.ArrayList<java.lang.String> getColumnNames()

getPrimaryKeys

public java.util.ArrayList<java.lang.String> getPrimaryKeys()

getTableCatalog

public java.lang.String getTableCatalog()

getTableName

public java.lang.String getTableName()
Access the name of the table for which this object was created.

Returns:
name of the table

getTablenameSupplied

public java.lang.String getTablenameSupplied()

getTableSchema

public java.lang.String getTableSchema()

getTableType

public java.lang.String getTableType()

insertArray

public int insertArray(RowSet rows)
                throws java.sql.SQLException
Insert a batch (array) of rows

Parameters:
rows - - Rows to be inserted in RowSet format
Returns:
Number of rows inserted
Throws:
java.sql.SQLException

updateRow

public int updateRow(Row updateRow)
              throws java.sql.SQLException
Apply row changes to the database. The supplied row must contain primary key values for the row to be updated. An update statement is genereated to apply changes to all non-primary key columns

Parameters:
Row - object containing updated values.
Returns:
Throws:
java.sql.SQLException