|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--it.mokabyte.pattern.dao.TheDao
This is an Helper class implementing the Data Access Object (DAO) pattern to simplify database access to the MOKA_ACCOUNT table.
Table is :
ACCOUNT ID (VARCHAR(255)) NAME (VARCHAR(255)) ADDRESS (VARCHAR(255)) BALANCE (DOUBLEPRECISION)
Field Summary | |
private it.mokabyte.pattern.dao.DataSource |
dataSource
The datasource for this helper dao |
Constructor Summary | |
TheDao(java.lang.String dataSourceName)
Retrieve the datasource from JNDI using the given name. |
Method Summary | |
boolean |
accountExists(AccountPK key)
|
private void |
closeResources(java.sql.Connection con,
java.sql.PreparedStatement stmt,
java.sql.ResultSet rslt)
Close all Database-Resources passed in. |
int |
deleteAccount(AccountPK pk)
Delete a row from the ACCOUNT table. |
java.util.Collection |
getAllAccounts()
Retrieve all Accounts. |
int |
insertAccount(AccountPK pk,
java.lang.String name,
java.lang.String address,
double balance)
Insert a row into the MOKA_ACCOUNT table. |
AccountOM |
readAccount(AccountPK pk)
Get a user from MOKA_ACCOUNT table. |
int |
updateAccount(AccountPK key,
java.lang.String name,
java.lang.String address,
double balance)
Update a row from the MOKA_ACCOUNT table. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private it.mokabyte.pattern.dao.DataSource dataSource
Constructor Detail |
public TheDao(java.lang.String dataSourceName) throws javax.naming.NamingException
dataSourceName
- the JNDI name of the DataSource to look upjavax.naming.NamingException
- thrown for errors with JNDIMethod Detail |
public int insertAccount(AccountPK pk, java.lang.String name, java.lang.String address, double balance) throws java.sql.SQLException
INSERT INTO MOKA_ACCOUNT (ID, NAME, ADDRESS, BALANCE) VALUES (id,name,address,balance)
id
- for the accountname
- the account user nameaddress
- the account user addressbalance
- the initial balance for this accountjava.sql.SQLException
- thrown by the Driver to indicate a database errorpublic int deleteAccount(AccountPK pk) throws java.sql.SQLException
DELETE FROM MOKA_ACCOUNT WHERE ID = 'ID'
the
- primary keyjava.sql.SQLException
- thrown by the Driver to indicate a database errorpublic AccountOM readAccount(AccountPK pk) throws java.sql.SQLException
SELECT NAME,ADDRESS,BALANCE FROM MOKA_ACCOUNT WHERE ID = 'ID'
the
- primary keyjava.sql.SQLException
- thrown by the Driver to indicate a database errorpublic int updateAccount(AccountPK key, java.lang.String name, java.lang.String address, double balance) throws java.sql.SQLException
UPDATE MOKA_ACCOUNT SET BALANCE,NAME,ADDRESS = ... WHERE ID =
key
- the primary keyname
- user nameaddress
- user addressbalance
- user balancejava.sql.SQLException
- thrown by the Driver to indicate a database errorpublic boolean accountExists(AccountPK key) throws java.sql.SQLException
key
- the Primary Key for this account - it contains the
custID and acctTypejava.sql.SQLException
- thrown by the Driver to indicate a database errorpublic java.util.Collection getAllAccounts() throws java.sql.SQLException
SELECT ID FROM MOKA_ACCOUNT
java.sql.SQLException
- thrown by the Driver to indicate a database errorprivate void closeResources(java.sql.Connection con, java.sql.PreparedStatement stmt, java.sql.ResultSet rslt)
null
is an acceptable
value for all arguments.con
- The Connection to closestmt
- The PreparedStatement to closerslt
- The ResultSet to close
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |