|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--it.mokabyte.pattern.dao.MyDaoImpl
Title: MyDaoImpl
Description: class that implements the data access logic to DBMS by JDBC
Copyright: Copyright (c) 2002
Company:
Field Summary | |
private it.mokabyte.pattern.dao.DataSource |
dataSource
The datasource |
Constructor Summary | |
MyDaoImpl(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 MOKA_ACCOUNT table. |
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 MyDaoImpl(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 DAOException
INSERT INTO MOKA_ACCOUNT(ID, NAME, ADDRESS, BALANCE) VALUES (id,name,address,balance)
insertAccount
in interface MyDao
pk
- primary key for the accountname
- the account user nameaddress
- the account user addressbalance
- the initial balance for this accountDAOException
- thrown if a database errorpublic int deleteAccount(AccountPK pk) throws DAOException
DELETE FROM MOKA_ACCOUNT WHERE ID = 'ID'
deleteAccount
in interface MyDao
the
- primary keyDAOException
- thrown if a database errorpublic AccountOM readAccount(AccountPK pk) throws DAOException
SELECT NAME,ADDRESS,BALANCE FROM MOKA_ACCOUNT WHERE ID = 'ID'
readAccount
in interface MyDao
the
- primary keyDAOException
- thrown if a database errorpublic int updateAccount(AccountPK key, java.lang.String name, java.lang.String address, double balance) throws DAOException
UPDATE MOKA_ACCOUNT SET BALANCE,NAME,ADDRESS = ... WHERE ID =
updateAccount
in interface MyDao
key
- the primary keyname
- user nameaddress
- user addressbalance
- user balanceDAOException
- thrown if a database errorpublic boolean accountExists(AccountPK key) throws DAOException
accountExists
in interface MyDao
key
- the Primary Key for this accountDAOException
- thrown if 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 |