Rakesh API

biz.wedoit4u.databeans
Class CustomerHelper

java.lang.Object
  extended by biz.wedoit4u.databeans.CustomerHelper

final class CustomerHelper
extends java.lang.Object

A helper class that provides convenient methods to interact with the customers table. This class is meant to be used from the DatabaseHelper class, or other classes in this package only.

Copyright 2003, Rakesh Vidyadharan and wedoit4u.biz

Version:
$Id: CustomerHelper.java,v 1.4 2004/05/26 11:42:31 rakesh Exp $
Author:
Rakesh Vidyadharan 21st October 2003

Field Summary
(package private) static java.lang.String ALL_CUSTOMERS
          The statement that is executed to fetch all the records from the customers table.
(package private) static java.lang.String CUSTOMER_ID_SEQUENCE
          The sequence set in the database for the customer_id primary key column.
(package private) static java.lang.String DELETE_CUSTOMERS
          The delete statement to be executed to delete a record in the customers table identified by the primary key value.
(package private) static java.lang.String FIND_BY_CUSTOMER_TYPE
          The statement that is executed to fetch all the records in the customer table that belong to a specific customer_type_id.
(package private) static java.lang.String FIND_BY_USERNAME_AND_PASSWORD
          The statement that is executed to fetch the matching record from the customer table for the specified username value.
(package private) static java.lang.String INSERT_CUSTOMERS
          The statement that is executed to insert a new record into the customers table.
(package private) static java.lang.String SELECT_CUSTOMERS
          The statement that is executed to fetch a specific record from the customers table.
(package private) static java.lang.String UPDATE_CUSTOMERS
          The update statement to be executed to update a record in the customers table.
 
Constructor Summary
private CustomerHelper()
          Default constructor.
 
Method Summary
(package private) static void delete(int customerId)
          Delete the record from the database identified by the primary key value specified.
(package private) static java.util.Collection findAll()
          Return a Collection of Integer values that represent all the primary key values in the customers table.
(package private) static java.util.Collection findByCustomerType(int customerTypeId)
          Select specified records from the customers table that belong to the specified customer_type_id.
(package private) static int findByUsernameAndPassword(java.lang.String username, java.lang.String password)
          Select the record from the customers table that has the specified username and password values.
(package private) static int insert(int customerId, java.lang.String username, java.lang.String password, java.lang.String email, java.lang.String domain, char active, java.util.Date activationDate, java.util.Date expirationDate, int customerTypeId)
          Insert a new record into the customers table with the values specified.
(package private) static void select(CustomerBean cb)
          Select the specified record from the customers table.
(package private) static void update(CustomerBean cb)
          Update the values in the customers table with the specified values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CUSTOMER_ID_SEQUENCE

static final java.lang.String CUSTOMER_ID_SEQUENCE
The sequence set in the database for the customer_id primary key column.

See Also:
Constant Field Values

ALL_CUSTOMERS

static final java.lang.String ALL_CUSTOMERS
The statement that is executed to fetch all the records from the customers table.

See Also:
Constant Field Values

FIND_BY_CUSTOMER_TYPE

static final java.lang.String FIND_BY_CUSTOMER_TYPE
The statement that is executed to fetch all the records in the customer table that belong to a specific customer_type_id.

See Also:
Constant Field Values

FIND_BY_USERNAME_AND_PASSWORD

static final java.lang.String FIND_BY_USERNAME_AND_PASSWORD
The statement that is executed to fetch the matching record from the customer table for the specified username value.

See Also:
Constant Field Values

INSERT_CUSTOMERS

static final java.lang.String INSERT_CUSTOMERS
The statement that is executed to insert a new record into the customers table.

See Also:
Constant Field Values

SELECT_CUSTOMERS

static final java.lang.String SELECT_CUSTOMERS
The statement that is executed to fetch a specific record from the customers table.

See Also:
Constant Field Values

UPDATE_CUSTOMERS

static final java.lang.String UPDATE_CUSTOMERS
The update statement to be executed to update a record in the customers table.

See Also:
Constant Field Values

DELETE_CUSTOMERS

static final java.lang.String DELETE_CUSTOMERS
The delete statement to be executed to delete a record in the customers table identified by the primary key value.

See Also:
Constant Field Values
Constructor Detail

CustomerHelper

private CustomerHelper()
Default constructor. Cannot be instantiated.

Method Detail

findAll

static final java.util.Collection findAll()
                                   throws java.sql.SQLException,
                                          javax.naming.NamingException
Return a Collection of Integer values that represent all the primary key values in the customers table.

Returns:
Collection - The collection of primary key values.
Throws:
java.sql.SQLException - - If errors are encountered while fetching the records from the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

findByCustomerType

static final java.util.Collection findByCustomerType(int customerTypeId)
                                              throws java.sql.SQLException,
                                                     javax.naming.NamingException
Select specified records from the customers table that belong to the specified customer_type_id.

Parameters:
customerTypeId - - The customer_type_id value.
Returns:
Collection - The list of primary key values.
Throws:
java.sql.SQLException - - If errors are encountered while fetching the record from the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

findByUsernameAndPassword

static final int findByUsernameAndPassword(java.lang.String username,
                                           java.lang.String password)
                                    throws java.sql.SQLException,
                                           javax.naming.NamingException
Select the record from the customers table that has the specified username and password values.

Parameters:
username - - The username value.
password - - The username value.
Returns:
int - The customer_id value.
Throws:
java.sql.SQLException - - If errors are encountered while fetching the record from the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

select

static final void select(CustomerBean cb)
                  throws java.sql.SQLException,
                         javax.naming.NamingException
Select the specified record from the customers table. The values selected from the database are used to set the values of the bean fields.

Parameters:
cb - - The java bean instance that represents the record. The primary key value to use to look up the record is obtained from this bean.
Throws:
java.sql.SQLException - - If errors are encountered while fetching the record from the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

insert

static final int insert(int customerId,
                        java.lang.String username,
                        java.lang.String password,
                        java.lang.String email,
                        java.lang.String domain,
                        char active,
                        java.util.Date activationDate,
                        java.util.Date expirationDate,
                        int customerTypeId)
                 throws java.sql.SQLException,
                        javax.naming.NamingException
Insert a new record into the customers table with the values specified.

Parameters:
customerId - - The primary key values to use. If this is 0, then the next value from the CUSTOMER_ID_SEQUENCE is used.
username - - The username value.
password - - The password value.
email - - The email value.
domain - - The domain value.
active - - The active value.
activationDate - - The activation_date value.
expirationDate - - The expiration_date value.
customerTypeId - - The customer_type_id foreign key value.
Throws:
java.sql.SQLException - - If database errors are encountered while writing to the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

update

static final void update(CustomerBean cb)
                  throws java.sql.SQLException,
                         javax.naming.NamingException
Update the values in the customers table with the specified values.

Parameters:
cb - - The java bean that represents a record in the database.
Throws:
java.sql.SQLException - - If database errors are encountered while writing to the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

delete

static final void delete(int customerId)
                  throws java.sql.SQLException,
                         javax.naming.NamingException
Delete the record from the database identified by the primary key value specified.

Parameters:
customerId - - The customer_id primary key value.
Throws:
java.sql.SQLException - - If database errors are encountered while writing to the database.
javax.naming.NamingException - - If errors are encountered while getting a connection from the connection pool.

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan