Hi,Friends

Im facing problem in paging using jsp & oracle ,in this code only 1 to 10 values displying,when im clicking on next its displying nothing.Means not taking next values.

<%@ page language="java" import="java.sql.*;"%>
<html>
<head>
</head>
<body>
<br><br><br>
<%
int offset=0;
int ofset = 0;
if(request.getParameter("offset")!=null) {
offset= Integer.parseInt(request.getParameter("offset").toString());
}
int total_count = 0;
int total_page = 0;
int per_page =10;
String name="";
if(offset>1){
ofset = offset*per_page-per_page;
}
System.out.println("MySQL Connect Example.");
Connection conn = null;
String color = "#F9EBB3";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
      conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL",
      "newton" , "newton");
Statement stcount = conn.createStatement();
String strQuerycount = "select count(*) from userdetail ";
ResultSet rscount = stcount.executeQuery(strQuerycount);
if(rscount.next())
{
total_count=rscount.getInt(1);
}
if(total_count%per_page==0)
{
total_page = total_count/per_page;
}
else
{
total_page = total_count/per_page+1;
}
//out.println(total_count);
//out.println(total_page);
//out.println(ofset);
Statement st = conn.createStatement();
String strQuery =  "select * from userdetail where rownum>="+ofset+" and rownum<="+ofset+(per_page);
// out.println(strQuery);
ResultSet rs2=null;
ResultSet rs = st.executeQuery(strQuery);
// out.println("offset " + offset);
int count=0;
if(offset>1)
count=offset*per_page-per_page;		
%>
<br><br><br>
<table width="400px" align="center" style="border:1px solid #000000;" >
<tr><td colspan=8 align="center" style="background-color:ffeeff"><b>Transaction Report</b></td>
</tr>
<tr style="background-color:efefef;">
<td><b>SNo</b></td>
<td><b>Name</b></td>
<td><b>Address</b></td>
</tr>
<%
while(rs.next()){
if((count%2)==0){
color = "#eeffee";
}
else{
color = "#F9EBB3";
}
count++;
%>
<tr style="background-color:<%=color%>;">
<td><%=count%></td>
<td><%=rs.getString(1)%> </td>
<td><%=rs.getString(2)%> </td>
</tr>
<%
}
%>
</table>
<br><br>
<table width="100px" align="center" border=0><tr>
<%
if(count==0)
{
%>
<tr style="background-color:<%=color%>;">
<td colspan=8 align="center">No Record</td>
</tr>
<%
}
System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
if(offset>1){
int previous = offset-1;
%>
<td>
<a href="orderbooking.jsp?offset=<%=previous%>">Previous</a></td>
<%
}
if(total_page>0)
{
for(int i=1;i<=total_page;i++)
{
if(request.getParameter("offset")==null)
{
offset=1;
}
if(i==offset)
{
%>
<td>
<%=i%></td>
<%
}
else{
%>
<td>
<a href="orderbooking.jsp?offset=<%=i%>"><%=i%></a></td>
<%
}
}
}
if(offset<total_page)
{
int next = offset+1;
%>
<td>
<a href="orderbooking.jsp?offset=<%=next%>">Next</a></td>
<%
}
%>
</tr>
</table>
</body>
</html>

Oh come on, you expect us to help you when you would not even spend a few moments reading the Community Rules.

Please use code tags, its as easy as putting
[code=jsp] and [/code] around your code. It preserves any indentation (which you have hopefully done), syntax highlighting and most important of all makes it easy for us to copy you post and try working with it at our end.

<EDIT>
Also gives us details on what errors you are getting, or what is being output in your webserver's logs etc.

Sorry what i did...........

actully its showing only 10 records,when am clicking on next then its show field name but not displying records.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.