Home Answers Viewqa JSP-Servlet Pagination in jsp using oracle and not sql

 
 


premika
Pagination in jsp using oracle and not sql
1 Answer(s)      2 years and 4 months ago
Posted in : JSP-Servlet

I need the code for pagination in jsp using oracle. I already tried it with rownum between instead of limit in sql.Please do forward me the code as soon as possible.

View Answers

February 21, 2011 at 12:35 PM


JSP Pagination using Mysql database

<%@ page language="java" %>
<%@ page import="java.sql.*" %>
<%!
public int nullIntconvert(String str){
int num=0;
if(str==null) {
str="0";
}
else if((str.trim()).equals("null")) {
str="0";
}
else if(str.equals("")) {
str="0";
}
try{
num=Integer.parseInt(str);
}
catch(Exception e) { }
return num;
}
%>
<%
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
ResultSet rs1 = null;
ResultSet rs2 = null;
PreparedStatement ps1=null;
PreparedStatement ps2=null;

int showRows=10;
int totalRecords=10;
int totalRows=nullIntconvert(request.getParameter("totalRows"));
int totalPages=nullIntconvert(request.getParameter("totalPages"));
int iPageNo=nullIntconvert(request.getParameter("iPageNo"));
int cPageNo=nullIntconvert(request.getParameter("cPageNo"));

int startResult=0;
int endResult=0;
if(iPageNo==0) {
iPageNo=0;
}
else{
iPageNo=Math.abs((iPageNo-1)*showRows);
}
String query1="SELECT SQL_CALC_FOUND_ROWS * FROM student limit "+iPageNo+","+showRows+"";
ps1=conn.prepareStatement(query1);
rs1=ps1.executeQuery();

String query2="SELECT FOUND_ROWS() as cnt";
ps2=conn.prepareStatement(query2);
rs2=ps2.executeQuery();
if(rs2.next()) {
totalRows=rs2.getInt("cnt");
}
%>
<html>
<h3>Pagination of JSP page</h3>
<body>
<form>
<input type="hidden" name="iPageNo" value="<%=iPageNo%>">
<input type="hidden" name="cPageNo" value="<%=cPageNo%>">
<input type="hidden" name="showRows" value="<%=showRows%>">
<table width="100%" cellpadding="0" cellspacing="0" border="1" >
<tr>
<td>Roll No</td>
<td>Name</td>
<td>Marks</td>
<td>Grade</td>
</tr>
<%
while(rs1.next()){
%>
<tr>
<td><%=rs1.getInt("rollNo")%></td>
<td><%=rs1.getString("name")%></td>
<td><%=rs1.getInt("marks")%></td>
<td><%=rs1.getString("grade")%></td>
</tr>
<%
}
%>
<%
try{
if(totalRows<(iPageNo+showRows)) {
endResult=totalRows;
}
else{
endResult=(iPageNo+showRows);
}
startResult=(iPageNo+1);
totalPages=((int)(Math.ceil((double)totalRows/showRows)));
}
catch(Exception e){
e.printStackTrace();
}
%>
<tr>
<td colspan="3">
<div>
<%
int i=0;
int cPage=0;
if(totalRows!=0){
cPage=((int)(Math.ceil((double)endResult/(totalRecords*showRows))));

int prePageNo=(cPage*totalRecords)-((totalRecords-1)+totalRecords);
if((cPage*totalRecords)-(totalRecords)>0){
%>
<a href="pagination.jsp?iPageNo=<%=prePageNo%>&cPageNo=<%=prePageNo%>"> << Previous</a>
<%
}
for(i=((cPage*totalRecords)-(totalRecords-1));i<=(cPage*totalRecords);i++){
if(i==((iPageNo/showRows)+1)){%>
<a href="pagination.jsp?iPageNo=<%=i%>" style="cursor:pointer;color: red"><b><%=i%></b></a>
<%
}
else if(i<=totalPages){
%>
<a href="pagination.jsp?iPageNo=<%=i%>"><%=i%></a>
<%
}
}
if(totalPages>totalRecords && i<totalPages){
%>
<a href="pagination.jsp?iPageNo=<%=i%>&cPageNo=<%=i%>"> >> Next</a>
<%
}
}
%>
<b>Rows <%=startResult%> - <%=endResult%> Total Rows <%=totalRows%> </b>
</div></td></tr></table></form></body></html>









Related Pages:
Pagination in jsp using oracle and not sql
Pagination in jsp using oracle and not sql  I need the code for pagination in jsp using oracle. I already tried it with rownum between instead... Pagination using Mysql database <%@ page language="java" %> <%@ page
Pagination
Pagination  How to create pagination in jsp with EJB using MS SQL
pagination
pagination   Simple way for pagination in jsp using java script to display data without send database
Pagination
=rs2.getInt("cnt"); } %> Pagination of JSP page Terr_Code Terr_Name... = DriverManager.getConnection("jdbc:oracle:thin:@10.104.48.39:1521:XE","Industry","Retail
pagination
....   Here is a simple jsp pagination code where we have used mysql database...()) { totalRows=rs2.getInt("cnt"); } %> <html> <h3>Pagination of JSP...pagination  I need to give pagination with where condition (query
Pagination
Pagination  pagination in jsp   Hi Friend, Try...()) { totalRows=rs2.getInt("cnt"); } %> <html> <h3>Pagination of JSP...; } else{ iPageNo=Math.abs((iPageNo-1)*showRows); } String query1="SELECT SQL_CALC
pagination
;Pagination of JSP page</h3> <body> <form> <input type="hidden... me how to paginate questions without refreshing page   Here is a jsp code of pagination. In the given code,we have taken the database table student
pagination
pagination  how can i start pagination in jsp?   Hi Friend...;Pagination of JSP page</h3> <body> <form> <input type="hidden...="SELECT SQL_CALC_FOUND_ROWS * FROM student limit "+iPageNo+","+showRows+""; ps1
pagination
pagination  please let me know how to fetch records from database and display them using paging in jsp and struts
Jsp table Pagination
Jsp table Pagination  I tried the code already.But I dont want it with SQL.I want it for oracle database because I'm using oracle.So please help me with this issue. Thanks
jsp page connectivity with oracle - SQL
connectivity jsp with oracle. Please send the code for solving problem. thanks ...: a) If you are using oracle oci driver,you have to use: Connection connection... and password. b) If you are using oracle thin driver,you have to use: Connection
pagination problem - JSP-Servlet
pagination problem   Thanks sir for posting the answer.But i have 2...(),insert() methods using or importing employee class.finally i created a class using servlets in that i called a these methods,to call this servlet i created
pagination problem - JSP-Servlet
pagination problem  Thanks sir for posting the answer.But i have 2...(),insert() methods using or importing employee class.finally i created a class using servlets in that i called a these methods,to call this servlet i created
Pagination in jsp - JSP-Servlet
Pagination in jsp  I need an example of pagination in JSP using display tag
JSP Pagination
I could possibly use??   JSP Pagination pagination.jsp: <%@ page..."); } %> <html><h3>Pagination of JSP page</h3> <body><...JSP Pagination  Hi , I have several JSP's that displays data from
Oracle - SQL
D:\oracle\ora90\BIN\imp type this command if your are using oracle 9i...Oracle  I have one .dmp file. I want to import this file into oracle 9i and oracle 10g. wat is procedure and stepts. thanks u  Open
Pagination
Pagination  How to apply pagination in JSP. Please help
pagination
pagination  How to set pagination using java script to display data
Pagination
Pagination  How to implement pagination in struts using hibernate
Pagination
Pagination  I want to write one where condition in sql query in pagination concept
pagination in jsp - JDBC
pagination in jsp  Hi, I have millions of records in my oracle d.... Simple pagination in jsp... ------------------   Simple pagination in jsp Simple
Pagination in java
Pagination in java  How to handle pagination when there are records like say in millions in java? Or do we handle this using SQL? I as asked this question in an interview.   Hi, Its better to handle at SQL end. Just
java oracle connection problem - SQL
java oracle connection problem  I have successfully made connection with the oracle10g database that i am using and also able to put in data using JSP. But the codes that i have tried for fetching the data are not working even
Pagination
Pagination  I want to know how to use pagination in jsp. I have a list object from that i want to display 3 questions per page can u help me
Pagination with condition using servlet or jsp
Pagination with condition using servlet or jsp  Hi, Thanks... I retrieved using "String name=request.getParameter("name of that text box")", Then I want perform the pagination based on the string value(I mean pagination
Pagination Using Displaytag Lib
Pagination Using Displaytag Lib  I am using Struts 1.2 for my web based project. While using display tag lib in jsp for pagination, is there any substitute of using As I dont want to be dependent on any site(s). Please
Pagination
Pagination  how to use these two SQL_CALC_FOUND_ROWS, FOUND_ROWS in database? Is these are Columns in table
Pagination - JSP-Servlet
Pagination  I want to display only 10 records but my arraylist contains for example about 100 records... My jsp page should contain 10 records along with the pagination below.... like prev 1 2 3 4 5 next I am using
jsf pagination
()) { totalRows=rs2.getInt("cnt"); } %> <html> <h3>Pagination of JSP... on please give any solution . Thanks, Bhuban   Here is a jsp code of pagination. In the given code,we have taken the database table student(rollNo,name,marks
What's wrong with my pagination code in JSP?
What's wrong with my pagination code in JSP?  Dear experts, I've...; print("code sample");   JSP Pagination The given code retrieves...()){ totalRows=rs2.getInt("cnt"); } %> <html><h3>Pagination of JSP
pagination in hibernate with jsp
pagination in hibernate with jsp  Hi, plz give me example on pagination .   Hi Friend, We have used MySql database with JSP...>Pagination of JSP page</h3> <body> <form> <input type
pagination in JSP - JSP-Interview Questions
pagination in JSP  Hi! Everybody.. I am new to JSP. I am doing project using JSP. Everything is OK. When i am displaying the data from ResultSet... --------------------- Visit for more information. http://www.roseindia.net/jsp/ Thanks
Data types in Oracle 9i - SQL
Data types in Oracle 9i  Cn anyone tell me the difference between timestamp wih time zone and timestamp with local timezone datatypes in oracle 9i.  Hi Friend, On Using TIMESTAMP WITH TIME ZONE, oracle store timezone
jsp pagination
jsp pagination  I want to implement pagination on jsp page Each jsp page having some radio buttons, on click of next previous page selected radio buttons are reset. I want to maintain state of selected radio buttons on previous
jdbc-oracle - JDBC
jdbc-oracle  Hi! sub: image insertion in oracle: I inserted the image in oracle database using java through jdbc-odbc bridge driver... BE DISPLAYED BY SQL PLUS". How can I ensure that the images was really uploaded
SQL
SQL  How do you increase performance of a query? Using batch, pagination, increasing JVM memory size
how to save images in oracle using JSP
how to save images in oracle using JSP  how to insert images in oracle using jsp
how to save images in oracle using JSP
how to save images in oracle using JSP  how to insert images in oracle using jsp
Paging or pagination - Development process
Paging or pagination  1.how to do paging or pagination in jsp using... to get a correct values... I m sending my jsp code also please help me sir...("Starting index is "+startIndex); %> Pagination The Following
Oracle - SQL
Oracle  Oracle Begginers , if Downloadable Notes are there Please mention the site
oracle - SQL
oracle  what is meant by redo log file?  Hi Friend, In Oracle, a redo log file is used with each database. It records all changes made... to replay SQL statements. Thanks
oracle - SQL
oracle  what is the difference between sql *plus and isql *plus
oracle - SQL
oracle  can you suggest me a book regarding oracle and java even..  Hi friend, For more information on Oracle and Java Books visit to : http://www.roseindia.net/programming/books/Freejavabooks.shtml http
java and oracle - JSP-Servlet
Mysql for this purpose. Try the following code: Pagination of JSP
store pagination form fields - Struts
table. here iam using pagination for questions to be displayed to client... approach this task. iam using jstl in jsp to iterate the list object of different...store pagination form fields   hi,iam working online exams project
oracle - SQL
) from employee)); In Oracle, you can use the following query: select max
jsp-oracle validation - JDBC
jsp-oracle validation  Dear friends, my validation not takes place.... --------------------------------------- logoutaction.jsp --------------------------------------- oracle 10g...://www.roseindia.net/jsp/ Thanks. Amardeep   Hello I am try so many times
pagination in hibernate with jsp
pagination in hibernate with jsp  Hi, plz give me example on pagination .   Hi Friend, Visit Here Thanks
pagination - JSP-Servlet
friend, Simple pagination in jsp Simple pagination in JSP... Simple pagination in jsp Displaying Records...pagination  Hi, could u tell me how i will handle pagination