SimpleDSDAO

public class SimpleDSDAO extends DataSourceDAO

SimpleDSDAO is a concrete subclass of DataSourceDAO which provides some convenient methods for querying and updating its underlying data source. It should not be used directly when the underlying persistent storage would be changed to any kind that does not support Java DataSource.

Author:Hugo Y. K. Lam

Constructors

SimpleDSDAO

public SimpleDSDAO()

Creates a new instance of SimpleDSDAO.

Methods

createDVO

public DVO createDVO()

Creates a new instance of SimpleDSDVO.

find

public SimpleDSDVO find(Object[] keys)

Retrieves data from the data source by searching with the specified key values.

Parameters:
  • keys – the key values for querying the data source. The number, format, and sequence of the parameter values should match the key finder statement.
Throws:
  • DAOException – if errors found when retrieving data from the data source.
Returns:

a SimpleDSDVO found by the specified key values. If there are more than one DVO found, the first one will be returned. null will be returned if nothing was found.

find

public List find(String finder, Object[] paras)

Retrieves data from the data source as a List of DVO by searching with the specified data values.

Parameters:
  • finder – the name of the finder SQL statement.
  • paras – the parameter values used by the specified finder statement. The number, format, and sequence of the parameter values should match the statement. null if there is no parameter for the statement.
Throws:
  • DAOException – if errors found when retrieving data from the data source.
Returns:

a List of SimpleDSDVO found by the specified data values. An empty List will be returned if there is no matching data.

update

public int update(String sqlname, Object[] paras)

Update the data source with the specified data values.

Parameters:
  • sqlname – the name of the SQL statement to be used.
  • paras – the data values to be updated to the data source.
Throws:
  • DAOException – if errors found when updating data to the data source.
Returns:

an integer indicating the update result. Same as the value returned by java.sql.Statement.executeUpdate().