Package ejava.examples.daoex.dao
Class JDBCBookDAOImpl
- java.lang.Object
-
- ejava.examples.daoex.dao.JDBCBookDAOImpl
-
-
Field Summary
Fields Modifier and Type Field Description private Connectionconnection
-
Constructor Summary
Constructors Constructor Description JDBCBookDAOImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bookcreate(Book book)Add the book to the database.List<Book>findAll(int start, int count)Returns a collection of books, starting at the index provided and limiting the collection to the count value.Bookget(long id)Gets a book from the database by its ID.private PreparedStatementgetIdentityStatement(Connection c)private PreparedStatementgetInsertPreparedStatement(Connection c, Book book)voidremove(Book book)Removes a book from the database.voidsetConnection(Connection connection)Bookupdate(Book book)Updates the book in the database with the values in this object.
-
-
-
Field Detail
-
connection
private Connection connection
-
-
Method Detail
-
setConnection
public void setConnection(Connection connection)
-
create
public Book create(Book book) throws PersistenceException
Description copied from interface:BookDAOAdd the book to the database.- Specified by:
createin interfaceBookDAO- Throws:
PersistenceException
-
getInsertPreparedStatement
private PreparedStatement getInsertPreparedStatement(Connection c, Book book) throws SQLException
- Throws:
SQLException
-
getIdentityStatement
private PreparedStatement getIdentityStatement(Connection c) throws SQLException
- Throws:
SQLException
-
update
public Book update(Book book) throws PersistenceException
Description copied from interface:BookDAOUpdates the book in the database with the values in this object.- Specified by:
updatein interfaceBookDAO- Throws:
PersistenceException
-
get
public Book get(long id) throws PersistenceException
Description copied from interface:BookDAOGets a book from the database by its ID.- Specified by:
getin interfaceBookDAO- Throws:
PersistenceException
-
remove
public void remove(Book book) throws PersistenceException
Description copied from interface:BookDAORemoves a book from the database.- Specified by:
removein interfaceBookDAO- Throws:
PersistenceException
-
findAll
public List<Book> findAll(int start, int count) throws PersistenceException
Description copied from interface:BookDAOReturns a collection of books, starting at the index provided and limiting the collection to the count value.- Specified by:
findAllin interfaceBookDAO- Throws:
PersistenceException
-
-