/** * ************************************* COPIES * SECTION******************************************************************** */ public void createBorrower(Borrower bor) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { if (bor == null || bor.getBorrowerName() == null || bor.getBorrowerName().length() == 0 || bor.getBorrowerName().length() > 45 || bor.getBorrowerAddress() == null || bor.getBorrowerAddress().length() == 0 || bor.getBorrowerAddress().length() > 45 || bor.getBorrowerPhone() == null || bor.getBorrowerPhone().length() == 0 || bor.getBorrowerPhone().length() > 45) { throw new Exception("Borrower Name, Address, Phone cannot be empty or more than 45 Chars"); } else { BorrowerDAO bdao = new BorrowerDAO(conn); bdao.create(bor); conn.commit(); } } catch (Exception e) { e.printStackTrace(); conn.rollback(); } finally { conn.close(); } }
/** ******************************************************************************************* */ public void DeletePublisher(Publisher publisher) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { if (publisher == null || publisher.getPublisherName() == null || publisher.getPublisherName().length() == 0 || publisher.getPublisherName().length() > 45 || publisher.getPublisherAddress() == null || publisher.getPublisherAddress().length() == 0 || publisher.getPublisherAddress().length() > 45 || publisher.getPublisherPhone() == null || publisher.getPublisherPhone().length() == 0 || publisher.getPublisherPhone().length() > 45) { throw new Exception("The Publisher cannot be null"); } else { PublisherDAO pdao = new PublisherDAO(conn); pdao.delete(publisher); conn.commit(); } } catch (Exception e) { e.printStackTrace(); conn.rollback(); } finally { conn.close(); } }
/** *************************************************************************************** */ public void UpdateBorrower(Borrower bor) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { if (bor == null || bor.getCardNo() == 0 || bor.getBorrowerName() == null || bor.getBorrowerName().length() == 0 || bor.getBorrowerName().length() > 45 || bor.getBorrowerAddress() == null || bor.getBorrowerAddress().length() == 0 || bor.getBorrowerAddress().length() > 45 || bor.getBorrowerPhone() == null || bor.getBorrowerPhone().length() == 0 || bor.getBorrowerPhone().length() > 45) { throw new Exception("The Borrower cannot be null or CardNo can not be 0 "); } else { BorrowerDAO bordao = new BorrowerDAO(conn); bordao.update(bor); conn.commit(); } } catch (Exception e) { e.printStackTrace(); conn.rollback(); } finally { conn.close(); } }
public List<Genre> ListGenres() throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { GenreDAO gdao = new GenreDAO(conn); List<Genre> genres = gdao.readAll(); conn.commit(); return genres; } catch (Exception e) { e.printStackTrace(); return null; } finally { conn.close(); } }
public List<LibBranch> ListBranches() throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { LibBranchDAO lib = new LibBranchDAO(conn); List<LibBranch> branches = lib.readAll(); conn.commit(); return branches; } catch (Exception e) { e.printStackTrace(); return null; } finally { conn.close(); } }
/** * Create a connection based on specific database connection context. * * @return Connection */ protected Connection createConnection() { JdbcConnectionContext jdcc = (JdbcConnectionContext) getDatabaseConnectionContext(); Connection connection = null; if (jdcc.useConnectionPool()) { connection = ConnectionUtil.createPooledConnection(jdcc); } else { connection = ConnectionUtil.createConnection(jdcc); } if (connection == null) throw new CreateConnectionFailureException( "JdbcConnection:createConnection() failure for " + getConnectionName() + "."); return connection; }
public List<Borrower> ListBorrower() throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { BorrowerDAO bdao = new BorrowerDAO(conn); List<Borrower> bor = bdao.readAll(); conn.commit(); return bor; } catch (Exception e) { e.printStackTrace(); return null; } finally { conn.close(); } }
public List<Author> ListAuthors() throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { AuthorDAO adao = new AuthorDAO(conn); List<Author> authors = adao.readAll(); conn.commit(); return authors; } catch (Exception e) { e.printStackTrace(); return null; } finally { conn.close(); } }
public List<BookLoans> ListBookLoans() throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { BookLoansDAO bldao = new BookLoansDAO(conn); List<BookLoans> bookloanslist = bldao.readAll(); conn.commit(); return bookloanslist; } catch (Exception e) { e.printStackTrace(); return null; } finally { conn.close(); } }
public List<Publisher> ListPublisher() throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { PublisherDAO pdao = new PublisherDAO(conn); List<Publisher> publishers = pdao.readAll(); conn.commit(); return publishers; } catch (Exception e) { e.printStackTrace(); return null; } finally { conn.close(); } }
/** *************************************************************************************** */ public void DeleteBorrower(Borrower bor) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { if (bor == null) { throw new Exception("The Borrower cannot be null"); } else { BorrowerDAO bordao = new BorrowerDAO(conn); bordao.delete(bor); conn.commit(); } } catch (Exception e) { e.printStackTrace(); conn.rollback(); } finally { conn.close(); } }
/** *************************************************************************************** */ public Genre ListOneGenre(int genre_id) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { GenreDAO gdao = new GenreDAO(conn); Genre genre = gdao.readOne(genre_id); return genre; } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return null; } finally { conn.close(); } }
/** *************************************************************************************** */ public LibBranch ListOneBranche(int branchId) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { LibBranchDAO lib = new LibBranchDAO(conn); LibBranch branch = lib.readOne(branchId); return branch; } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return null; } finally { conn.close(); } }
/** *************************************************************************************** */ public Book ListOneBook(int bookId) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { BookDAO bdao = new BookDAO(conn); Book book = bdao.readOne(bookId); return book; } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return null; } finally { conn.close(); } }
/** *************************************************************************************** */ public Author ListOneAuthor(int authorId) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { AuthorDAO adao = new AuthorDAO(conn); Author author = adao.readOne(authorId); return author; } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return null; } finally { conn.close(); } }
/** *************************************************************************************** */ public Borrower ListOneBorrower(int cardNo) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { BorrowerDAO bdao = new BorrowerDAO(conn); Borrower bor = bdao.readOne(cardNo); return bor; } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return null; } finally { conn.close(); } }
/** *************************************************************************************** */ public Publisher ListOnePublisher(int PublisherId) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { PublisherDAO pdao = new PublisherDAO(conn); Publisher publisher = pdao.readOne(PublisherId); return publisher; } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return null; } finally { conn.close(); } }
/** *************************************************************************************** */ public BookLoans ListOneBookLoan(int bookId, int branchId, int cardNo) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { BookLoansDAO bldao = new BookLoansDAO(conn); BookLoans bookloans = bldao.readOne(bookId, branchId, cardNo); return bookloans; } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return null; } finally { conn.close(); } }
/** ******************************************************************************************* */ public void DeleteGenre(Genre genre) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { if (genre == null || genre.getGenreName().length() == 0 || genre.getGenreName().length() > 45) { throw new Exception("The Genre cannot be null"); } else { GenreDAO gdao = new GenreDAO(conn); gdao.delete(genre); conn.commit(); } } catch (Exception e) { e.printStackTrace(); conn.rollback(); } finally { conn.close(); } }
/** ******************************************************************************************* */ public void DeleteBook(Book book) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { if (book == null || book.getTitle() == null || book.getTitle().length() == 0 || book.getTitle().length() > 45) { throw new Exception("The Book cannot be null"); } else { BookDAO bdao = new BookDAO(conn); bdao.delete(book); conn.commit(); } } catch (Exception e) { e.printStackTrace(); conn.rollback(); } finally { conn.close(); } }
/** *************************************************************************************** */ public void DeleteBookLoans(BookLoans bookloan) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { if (bookloan == null || bookloan.getDateOut() == null || bookloan.getDueDate() == null || bookloan.getDateOut().after(bookloan.getDueDate())) { throw new Exception("The Borrower cannot be null"); } else { BookLoansDAO bookLdao = new BookLoansDAO(conn); bookLdao.delete(bookloan); conn.commit(); } } catch (Exception e) { e.printStackTrace(); conn.rollback(); } finally { conn.close(); } }
/** *************************************************************************************** */ public void DeleteAuthor(Author author) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { if (author == null || author.getAuthorName() == null || author.getAuthorName().length() == 0 || author.getAuthorName().length() > 45) { throw new Exception("The Author cannot be null"); } else { AuthorDAO adao = new AuthorDAO(conn); adao.delete(author); conn.commit(); } } catch (Exception e) { e.printStackTrace(); conn.rollback(); } finally { conn.close(); } }
/** *************************************************************************************** */ public void UpdateBookloans(BookLoans bookloans) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { if (bookloans == null || bookloans.getCardNo() == 0 || bookloans.getBookId() == 0 || bookloans.getBranchId() == 0 || bookloans.getDateOut() == null || bookloans.getDueDate() == null || bookloans.getDateOut().after(bookloans.getDueDate())) { throw new Exception("The Borrower cannot be null or CardNo can not be 0 "); } else { BookLoansDAO bookldao = new BookLoansDAO(conn); bookldao.update(bookloans); conn.commit(); } } catch (Exception e) { e.printStackTrace(); conn.rollback(); } finally { conn.close(); } }
/** *************************************************************************************** */ public void DeleteLibBranch(LibBranch branch) throws Exception { ConnectionUtil c = new ConnectionUtil(); Connection conn = c.createConnection(); try { if (branch == null || branch.getLibraryBranchName() == null || branch.getLibraryBranchName().length() == 0 || branch.getLibraryBranchName().length() > 45 || branch.getLibraryBranchAddress() == null || branch.getLibraryBranchAddress().length() == 0 || branch.getLibraryBranchAddress().length() > 45) { throw new Exception("The Book cannot be null"); } else { LibBranchDAO lib = new LibBranchDAO(conn); lib.delete(branch); conn.commit(); } } catch (Exception e) { e.printStackTrace(); conn.rollback(); } finally { conn.close(); } }