Yes i have followed all your instructions dear friend yet it is still the same issue! cannot show the record.
String count = request.getParameter("Counter");
int Counter = 0;
BookRecordViews Book = (BookRecordViews)GetBookRecord.get(Counter);
<a href="ViewBooks.jsp?Counter=<%=Counter+1%>">View Next Record</a>
<a href="ViewBooks.jsp?Counter=<%=Counter-1%>">View Previous Record</a>
All this code is done in accordance to your previous posts! Still NO LUCK! Or cud there be a problem in the ArrayList for the java file?
Here is the java code once again! Im showing everything that i can:
DAO.java {This is the DATA ACCESS OBJECT Pattern file}
private BookRecordViews populateBookObject (ResultSet Results)
throws ClassNotFoundException , SQLException
{
int BookID = Integer.parseInt(Results.getString("BookID"));
String BookName = Results.getString("BookName");
String DateOfArrival = Results.getString("DateOfArrival");
String DateOfPublish = Results.getString("DateOfPublish");
String AuthorName = Results.getString("AuthorName");
int StudentID = Integer.parseInt(Results.getString("StudentID"));
int LecturerID = Integer.parseInt(Results.getString("LecturerID"));
String Available = Results.getString("Available");
String Category = Results.getString("Category");
return new BookViews(BookID, BookName, DateOfArrival, DateOfPublish, AuthorName, StudentID, LecturerID, Available, Category);
} // This Method Populates the Book Records and gets the fields from BookViews.java
public ArrayList<BookRecordViews> GetBookRecord()
throws ClassNotFoundException , SQLException
{
try
{
ArrayList<BookRecordViews> BookRecords = new ArrayList<BookRecordViews>();
Statement SQLStatement = getDatabaseConnection();
String SQLQuery = "SELECT * FROM Book;";
ResultSet BookResult = SQLStatement.executeQuery(SQLQuery);
while(BookResult.next())
{
BookRecords.add(populateBookObject(BookResult));
}
DestroySQLConnection();
return BookRecords;
}
catch (ClassNotFoundException cnfe)
{
System.out.println(cnfe);
throw cnfe;
}
catch (SQLException SQLE)
{
System.out.println(SQLE);
throw SQLE;
}
} //This Is The Arraylist from where Records Concerning the Books are listed in Array.
BookRecordViews with the getter and setter methods.
package DataAccessObject;
/**
*
* @author Sagar Joshi
*/
public interface BookRecordViews {
public int getBookID();
public void setBookID(int BookID);
public String getBookName();
public void setBookName(String BookName);
public String getDateOfArrival();
public void setDateOfArrival(String DateOfArrival);
public String getDateOfPublish();
public void setDateOfPublish(String DateOfPublish);
public String getAuthorName();
public void setAuthorName(String AuthorName);
public int getStudentID();
public void setStudentID(int StudentID);
public int getLecturerID();
public void setLecturerID(int LecturerID);
public String getAvailability();
public void setAvailability(String Available);
public String getCategory();
public void setCategory(String Category);
} // Variables Are Listed.
BookViews.java (implements the BookRecordViews)
package DataAccessObject;
/**
*
* @author Sagar Joshi
*/
public class BookViews implements BookRecordViews {
private int BookID;
private String BookName;
private String DateOfArrival;
private String DateOfPublish;
private String AuthorName;
private int StudentID;
private int LecturerID;
private String Available;
private String Category;
public BookViews()
{
}
public BookViews(int BookID , String BookName , String DateOfArrival , String DateOfPublish , String AuthorName , int StudentID , int LecturerID
, String Available , String Category)
{
this.BookID = BookID;
this.BookName = BookName;
this.DateOfArrival = DateOfArrival;
this.DateOfPublish = DateOfPublish;
this.AuthorName = AuthorName;
this.StudentID = StudentID;
this.LecturerID = LecturerID;
this.Available = Available;
this.Category = Category;
}
public int getBookID()
{
return BookID;
}
public void setBookID(int BookID)
{
this.BookID = BookID;
}
public String getBookName()
{
return BookName;
}
public void setBookName(String BookName)
{
this.BookName = BookName;
}
public String getDateOfArrival()
{
return DateOfArrival;
}
public void setDateOfArrival(String DateOfArrival)
{
this.DateOfArrival = DateOfArrival;
}
public String getDateOfPublish()
{
return DateOfPublish;
}
public void setDateOfPublish(String DateOfPublish)
{
this.DateOfPublish = DateOfPublish;
}
public String getAuthorName()
{
return AuthorName;
}
public void setAuthorName(String AuthorName)
{
this.AuthorName = AuthorName;
}
public int getStudentID()
{
return StudentID;
}
public void setStudentID(int StudentID)
{
this.StudentID = StudentID;
}
public int getLecturerID()
{
return LecturerID;
}
public void setLecturerID(int LecturerID)
{
this.LecturerID = LecturerID;
}
public String getAvailability()
{
return Available;
}
public void setAvailability(String Available)
{
this.Available = Available;
}
public String getCategory()
{
return Category;
}
public void setCategory(String Category)
{
this.Category = Category;
}
} // Contains The Getter and Setter Method.
The JSP once again
OshwalDAO dao = DAO.getDAOInterface();
ArrayList GetBookRecord = dao.GetBookRecord();
//String StudentRecord = dao.GetStudentRecordForDelete();
%>
<table align="center" border="1" frame="2" id="table" width="1020">
<tr><td><b>Book ID</b></td><td><b>Book Name</b></td><td><b>Date Of Arrival</b></td><td><b>Date Of Publish</b></td><td><b>Author Name</b></td><td><b>Student ID</b></td>
<td><b>Lecturer ID</b></td><td><b>Available</b></td><td><b>Category</b></td></tr>
<%
String Count = request.getParameter("Counter");
int Counter= 0;
BookRecordViews Book = (BookRecordViews)GetBookRecord.get(Counter);
%>
<tr>
<td><%=Book.getBookID()%></td>
<td><%=Book.getBookName() %></td>
<td><%=Book.getDateOfArrival() %></td>
<td><%=Book.getDateOfPublish() %></td>
<td><%=Book.getAuthorName() %></td>
<td><%=Book.getStudentID() %></td>
<td><%=Book.getLecturerID() %></td>
<td><%=Book.getAvailability()%></td>
<td><%=Book.getCategory()%></td>
<td><a href="ViewBooks.jsp?Counter=<%Counter+1%>">Next Record</a></td>
<td><a href="ViewBooks.jsp?Counter=<%Counter-1%>">Previous Record</a></td>
</tr>
<% //} %>
</table>
</body>
</html>
Everything i did yet no result!