Package ejava.examples.daoex.dao
Class JDBCBookDAOImpl
- java.lang.Object
-
- ejava.examples.daoex.dao.JDBCBookDAOImpl
-
-
Field Summary
Fields Modifier and Type Field Description private Connection
connection
-
Constructor Summary
Constructors Constructor Description JDBCBookDAOImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Book
create(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.Book
get(long id)
Gets a book from the database by its ID.private PreparedStatement
getIdentityStatement(Connection c)
private PreparedStatement
getInsertPreparedStatement(Connection c, Book book)
void
remove(Book book)
Removes a book from the database.void
setConnection(Connection connection)
Book
update(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:BookDAO
Add the book to the database.- Specified by:
create
in 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:BookDAO
Updates the book in the database with the values in this object.- Specified by:
update
in interfaceBookDAO
- Throws:
PersistenceException
-
get
public Book get(long id) throws PersistenceException
Description copied from interface:BookDAO
Gets a book from the database by its ID.- Specified by:
get
in interfaceBookDAO
- Throws:
PersistenceException
-
remove
public void remove(Book book) throws PersistenceException
Description copied from interface:BookDAO
Removes a book from the database.- Specified by:
remove
in interfaceBookDAO
- Throws:
PersistenceException
-
findAll
public List<Book> findAll(int start, int count) throws PersistenceException
Description copied from interface:BookDAO
Returns a collection of books, starting at the index provided and limiting the collection to the count value.- Specified by:
findAll
in interfaceBookDAO
- Throws:
PersistenceException
-
-