org.dbforms.event.datalist.dao
Class DataSourceJDBC

java.lang.Object
  extended by org.dbforms.event.datalist.dao.AbstractDataSource
      extended by org.dbforms.event.datalist.dao.DataSourceJDBC

public class DataSourceJDBC
extends AbstractDataSource

Special implementation of DataSource. This is the default class and deals with JDBC Connections.

Author:
hkk

Constructor Summary
DataSourceJDBC()
          Creates a new DataSourceJDBC object.
 
Method Summary
protected  void close()
          Release all the resources holded by this datasource.
 int doDelete(DbEventInterceptorData interceptorData, String keyValuesStr)
          performs a delete in the DataSource
 int doInsert(DbEventInterceptorData interceptorData, FieldValues fieldValues)
          Performs an insert into the DataSource
 int doUpdate(DbEventInterceptorData interceptorData, FieldValues fieldValues, String keyValuesStr)
          Performs an update into the DataSource
protected  int findStartRow(String startRow)
          Find the first row of the internal data vector.
protected  Object[] getRow(int i)
          Get the requested row as array of objects.
protected  int getRowCount()
          DOCUMENT ME!
protected  boolean hasMore(int i)
          return true if there are more records to fetch then the given record number
 boolean isCalcRowCount()
          DOCUMENT ME!
protected  void open()
          Open this datasource and initialize its resources.
 void setCalcRowCount(boolean calcRowCount)
          DOCUMENT ME!
protected  void setConnection(Connection con, String dbConnectionName)
          set the connection parameter for the DataSouce. virtual method, if you need the connection data you must override the method In this special case we need our own connection to save it in the session.
 void setSelect(FieldValue[] filterConstraint, FieldValue[] orderConstraint, String sqlFilter, FieldValue[] sqlFilterParams)
          Set the filterConstraint and orderConstraint used to build the SQL Select condition.
 void setSelect(String tableList, String whereClause)
          Set the tableList and whererClause attributes used to build the SQL Select condition.
protected  int size()
          Get the size of the data vector.
 
Methods inherited from class org.dbforms.event.datalist.dao.AbstractDataSource
deleteBlobFilesFromDisk, getCurrent, getFirst, getLast, getNext, getPrev, getResultSetVector, getTable, saveBlobFilesToDisk, setTable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSourceJDBC

public DataSourceJDBC()
Creates a new DataSourceJDBC object.

Method Detail

setCalcRowCount

public void setCalcRowCount(boolean calcRowCount)
DOCUMENT ME!

Parameters:
calcRowCount - The calcRowCount to set.

isCalcRowCount

public boolean isCalcRowCount()
DOCUMENT ME!

Returns:
Returns the calcRowCount.

setSelect

public void setSelect(String tableList,
                      String whereClause)
Set the tableList and whererClause attributes used to build the SQL Select condition.

Overrides:
setSelect in class AbstractDataSource
Parameters:
tableList - the table list string
whereClause - the SQL where clause string

setSelect

public void setSelect(FieldValue[] filterConstraint,
                      FieldValue[] orderConstraint,
                      String sqlFilter,
                      FieldValue[] sqlFilterParams)
Set the filterConstraint and orderConstraint used to build the SQL Select condition.

Specified by:
setSelect in class AbstractDataSource
Parameters:
filterConstraint - FieldValue array used to build a cumulation of rules for filtering fields.
orderConstraint - FieldValue array used to build a cumulation of rules for ordering (sorting) and restricting fields.
sqlFilter - sql condition to add to where clause
sqlFilterParams - list of FieldValues to fill the sqlFilter with

doDelete

public int doDelete(DbEventInterceptorData interceptorData,
                    String keyValuesStr)
             throws SQLException
performs a delete in the DataSource

Overrides:
doDelete in class AbstractDataSource
Parameters:
interceptorData - DOCUMENT ME!
keyValuesStr - keyValueStr to the row to update
key format: FieldID ":" Length ":" Value
example: if key id = 121 and field id=2 then keyValueStr contains "2:3:121"
If the key consists of more than one fields, the key values are seperated through "-"
example: value of field 1=12, value of field 3=1992, then we'll get "1:2:12-3:4:1992"
Throws:
SQLException

doInsert

public int doInsert(DbEventInterceptorData interceptorData,
                    FieldValues fieldValues)
             throws SQLException
Performs an insert into the DataSource

Overrides:
doInsert in class AbstractDataSource
Parameters:
interceptorData - DOCUMENT ME!
fieldValues - FieldValues to insert
Throws:
SQLException

doUpdate

public int doUpdate(DbEventInterceptorData interceptorData,
                    FieldValues fieldValues,
                    String keyValuesStr)
             throws SQLException
Performs an update into the DataSource

Overrides:
doUpdate in class AbstractDataSource
Parameters:
interceptorData - DOCUMENT ME!
fieldValues - FieldValues to update
keyValuesStr - keyValueStr to the row to update
key format: FieldID ":" Length ":" Value
example: if key id = 121 and field id=2 then keyValueStr contains "2:3:121"
If the key consists of more than one fields, the key values are seperated through "-"
example: value of field 1=12, value of field 3=1992, then we'll get "1:2:12-3:4:1992"
Throws:
SQLException

setConnection

protected void setConnection(Connection con,
                             String dbConnectionName)
set the connection parameter for the DataSouce. virtual method, if you need the connection data you must override the method In this special case we need our own connection to save it in the session.

Overrides:
setConnection in class AbstractDataSource
Parameters:
con - the JDBC Connection object
dbConnectionName - name of the used db connection. Can be used to get an own db connection, e.g. to hold it during the session (see DataSourceJDBC for example!)

getRow

protected final Object[] getRow(int i)
                         throws SQLException
Get the requested row as array of objects.

Specified by:
getRow in class AbstractDataSource
Parameters:
i - the row number
Returns:
the requested row as array of objects
Throws:
SQLException - if any error occurs

close

protected final void close()
Release all the resources holded by this datasource.
Clean the underlying data and keys vectors, then close the JDBC resultSet, statement and connection objects.

Specified by:
close in class AbstractDataSource

findStartRow

protected final int findStartRow(String startRow)
                          throws SQLException
Find the first row of the internal data vector.

Specified by:
findStartRow in class AbstractDataSource
Parameters:
startRow - the string identifying the initial row
Returns:
the start row position
Throws:
SQLException - if any error occurs

hasMore

protected final boolean hasMore(int i)
                         throws SQLException
return true if there are more records to fetch then the given record number

Specified by:
hasMore in class AbstractDataSource
Parameters:
i - index of last fetched row.
Returns:
true if there are more records to fetch then the given record number
Throws:
SQLException

open

protected void open()
             throws SQLException
Open this datasource and initialize its resources.

Specified by:
open in class AbstractDataSource
Throws:
SQLException - if any error occurs

size

protected final int size()
                  throws SQLException
Get the size of the data vector.

Specified by:
size in class AbstractDataSource
Returns:
the size of the data vector
Throws:
SQLException - if any error occurs

getRowCount

protected int getRowCount()
DOCUMENT ME!

Returns:
Returns the rowCount.


Copyright © 2002-2006 DbForms. All Rights Reserved.