JSP Pagination with JDBC Database result

I would like to have pagination for my JSP app. Has anyone ever done it using JDBC? What if the result is huge
Just wondering if I get a result of 40,000 and the page would take a long time to load just to show the first few results. Should I store it in a collection and pass it on to the next page? Thanks

We get the entire record list from the database and store it in the session. Then, use index counters to track which portion of the list to display.
It would be cool if we could just get selected portions out of the database, but then that might mean several database.
However, our design method makes it easy to sort the list by any column at any time.

Similar Messages

  • The jdbcTable.jsp example with Sybase database??

    Hi there,
              Does anyone got the jdbcTable.jsp example working with Sybase
              jConnect?
              Thank you
              

    David,
    Thanks for the suggestion. We'll schedule that on our list of new sample portlets.
    But as a sidenote, the Database access would really be no different from any standard JDBC calls to connect to and query the database.

  • RecordSet in JSP page with MySQL database

    I want to create a recordset for my jsp page but i don't know how to do it at all. I know that I need a connection , a statement and a RecordSet. But after that I am Lost.
    I want "First" "Previous" "Next" "Last" to be shown as hyperlinks into my webpage

    Sorry when I say Recondset I mean <b >RecordSet Navigator</b>

  • JSP and Access 2007 database

    i've been trying to look for codes on how to access the Access 2007 database (.accdb).
    i've done a previous JSP app with Access database, but it is of a lower version (.mdb).
    i need something like the following, but for the 2007 version. is it just a matter of changing the extension for both statements, or is there more to it?
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String DBQ = request.getRealPath("sales.mdb");
    String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + DBQ + ";DriverID=22;READONLY=true";thanks.

    <%@page import="java.sql.*" %>
    <table boder="1">
    <%
    Statement statement;
    Connection conn;
    String url = "jdbc:mysql://localhost/dbName";
    String user = "username";
    String pass = "password";
    try {
        class.forName("com.mysql.jdbc.Driver");
        conn = DriverManager.getConnection(url, user, pass);
        statement = conn.createStatement();
    String query = "SELECT images FROM database";
    ResultSet results = statement.executeQuery(query);
    while(results.next()) {
    %>
        <tr>
            <td><img src="<%= results.getString("images") %>"></td>
        </tr>
    <% } %>
    </table>The while loop will loop through your result set and print the table row for each image it finds in the query.
    Hope this helps,
    Jon

  • I need help with paginating my Oracle database records in JSP

    Please can someone help with a script that allows me to split my resultsets from an Oracle database in JSP...really urgent..any help would be really appreciated. I'm using the Oracle Apache http server and JSP environment that comes with the database...thanks

    First thing you have to do is decide on a platform and
    database. Check to see what your server supports. Whether it is ASP
    and MSSQL, PHP and MySQL or less likely Cold Fusion.

  • Pagination with orcale and jsp

    hi, i m new to java can any one tell me how to do pagination with my this codes
    String sqlCount = null;
    String sql = null;
    sql = "select * from HOME_LEASE_ ";
    sqlCount = "select count(*)from HOME_LEASE_ ";
    Enumeration e = request.getParameterNames();
    int i = 0;
    while(e.hasMoreElements()){
    String name = (String)e.nextElement();
    String search = new String(request.getParameter(name)).toUpperCase();
    if(i != 0 && (!search.isEmpty())){
    sql = sql +" and " + name +" like'" + search + "%'" ;
    sqlCount = sqlCount + " and " name" like '" + search + "%'" ;
    }else if((!search.isEmpty()) && (i == 0) ){
    sql = sql + " where " + name +" like '" + search + "%'" ;
    sqlCount = sqlCount + " where " + name+" like '" + search + "%'" ;
    ++i;
    if((sql != null) && (sqlCount != null)){
    DataAccess dB = new DataAccess();
    Connection conn = dB.getConnection();
    Statement stmtCount = dB.createStmt(conn);
    ResultSet rsCount = dB.executeQuery(sqlCount,stmtCount);
    rsCount.next();
    Statement stmt = dB.createStmt(conn);
    ResultSet rs = dB.executeQuery(sql,stmt);
    <% if(rs == null)
    out.println("<h3>No data found</h3>");
    else
    //out.println(rs.next());
    while(rs.next()) {
    //out.println("inside the result set");
    out.println("<tr>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("phase") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("file_no") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getString("se") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getString("str") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getString("qrno") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getString("typ") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("perno") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getString("name") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("total_plot_area_ocp") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("TOT_PREM_AREA") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("total_construction") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getLong("chargbl_construction") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getLong("add_open_construction") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getLong("TOT_PREM_AREA") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getLong("plinth") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getLong("std_plot_area") + "</a></td>");
    out.println("</tr>");
    dB.close(rsCount);
    dB.close(stmtCount);
    dB.close(rs);
    dB.close(stmt);
    dB.close(conn);
    }else{
    out.println("<center style=\"background-color:red\">Please enter values in text fields<h1></h1></center>");
    %>

    After examining your code, I think:
    You are not using JSP/HTML properly (using java to write out HTML). You can spend a tremendous amount of time with trial and error approaches in learning a technology and still not get much real understanding for your effort. I suggest a better use of those hours would be spent in reading a book on Java first, then a book on JSP. For a book on JSP, go to amazon.com and search for 'Javaserver pages'. Find a book that isn't too old and that has good reviews. Here is one (although its a bit dated):
    http://www.amazon.com/JavaServer-Pages-Edition-Hans-Bergsten/dp/0596005636/ref=sr_1_1?s=books&ie=UTF8&qid=1338821741&sr=1-1
    As far your database code goes, I suggest you read on-line articles on JDBC on how to get/use/close a database connection in a try/catch/finally block. The article will probably also help you write better SQL too. I don't think your question on pagination should be tackled until you learn JSP.

  • Problem with JDBC results calling simple stored procedure in VC 7.0

    Hi all,
    I am building a simple VC model which calls a stored procedure on a JDBC database. I have created the system in the portal, defined the alias and user mapping, the connection test is fine and the VC "find data" lists my bespoke stored procedure.
    The stored procedure is :
    CREATE PROCEDURE dbo.dt_getBieUsers
    AS
    select * from dbo.emailuserlink
    GO
    When I test it using query analyser, it returns 3 records each with the two fields I expect - user and email address.
    I drag the model onto the workspace in VC and create an input form ( with just a submit button ). i drag the result port out to create a table. This has no fields in it.
    I build and deploy as flex and the app runs, I click the submit button and SUCCESS! I get 3 records in my table each with 2 fields. The data is all correct. The problem with this is the fields are determined at runtime it seems.
    I go back to the table and add 2 columns "email" and "address".
    i build and deploy and run the app. Again I get 3 records, but this time the contents of all of the rows is not data, but "email" and "address". The data has been replaced by the header texts in all of the rows.
    Can anyone help? Why isn't the data being put in my columns as I would expect?
    I tried to build and deploy the app as Web Dynpro rather than Flex to see if it was a bug in Flex. The application starts but when I click the submit button to run the JDBC stored procedure I get a 500 Internal Server Error
    com.sap.tc.wd4vc.intapi.info.exception.WD4VCRuntimeException: No configuration is defined for the entry JDBCFunction
        at com.sap.tc.wd4vc.xglengine.XGLEngine.createComponentInternal(XGLEngine.java:559)
        at com.sap.tc.wd4vc.xglengine.XGLEngine.getCompInstanceFromUsage(XGLEngine.java:362)
        at com.sap.tc.wd4vc.xglengine.XGLEngine.getCompInstance(XGLEngine.java:329)
        at com.sap.tc.wd4vc.xglengine.wdp.InternalXGLEngine.getCompInstance(InternalXGLEngine.java:167)
        at com.sap.tc.wd4vc.xglengine.XGLEngineInterface.getCompInstance(XGLEngineInterface.java:165)
    The JDBC connection I am using has a connection URL of jdbc:sap:sqlserver://localhost;DatabaseName=BIEUSERS
    and a driver class of com.sap.portals.jdbc.sqlserver.SQLServerDriver
    Can anyone solve my wierd problems?
    Cheers
    Richard

    Hi Richard,
    After you drag and drop the data service, right click on it and choose "Test data service". Then click on "Execute" and after you see the result on the right, click on "Add fields" button (inside the same window). Now you'll see that the fields are on the tabel. This is required only for JDBC data services, since this data (how the resultset is built) is not know in DT and it needs to be run firest - then analysed and only then you have to add the fields to the table).
    Regards,
    Natty

  • How to connect mySQL database with jdbc

    Who can tell me how to connect mySQL database with jdbc? Thanks

    http://onesearch.sun.com/search/developers/index.jsp?and=connect+mysql&nh=10&phr=&qt=&not=&field=title&since=&col=devforums&rf=0&Search.x=24&Search.y=16

  • Upload file in JSP with Oracle Database 10gR2

    How to upload file with oracle database 10gR2??
    i can't find how to upload..
    i've tried to create a procedure in oracle and execute in netbeans but the file save in directory and then from directory save to database.
    it means the file save in 2 location, in directory and database..
    does anybody know how to save file direct from the JSP file into database without save in directory?
    this is the procedure..
    create or replace PROCEDURE load_file (
    p_id number,
    p_photo_name in varchar2) IS
    src_file BFILE;
    dst_file BLOB;
    lgh_file BINARY_INTEGER;
    BEGIN
    src_file := bfilename('DIR_TEMP', p_photo_name);
    -- insert a NULL record to lock
    INSERT INTO temp_photo
    *(id, photo_name, photo)*
    VALUES
    *(p_id , p_photo_name ,EMPTY_BLOB())*
    RETURNING photo INTO dst_file;
    -- lock record
    SELECT photo
    INTO dst_file
    FROM temp_photo
    WHERE id = p_id
    AND photo_name = p_photo_name
    FOR UPDATE;
    -- open the file
    dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
    -- determine length
    lgh_file := dbms_lob.getlength(src_file);
    -- read the file
    dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
    -- update the blob field
    UPDATE temp_photo
    SET photo = dst_file
    WHERE id = p_id
    AND photo_name = p_photo_name;
    -- close file
    dbms_lob.fileclose(src_file);
    END load_file;

    Well your Oracle procedure is designed to load a file, so that's what it does. If you want it to load from a data stream such as an upload, you need to rewrite it accordingly.
    So far this is not a Java question at all.

  • JSP with Access Database

    Could I use Access Database in JSP source code without Having DSN (DSN-less)
    I mean i do not want to set up a DSN in Control panel.
    I want only give JSP code a access database (.mdb)
    Please tell me the Connection String.
    Thank you

    try the following code:
    String url = System.getProperty("user.dir")+"\\db1.mdb";
    String conStr = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ="+url;
    try{
    System.out.println(conStr);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection(conStr);
    JOptionPane.showMessageDialog(this,"connection created");
    }catch(Exception e){System.out.println("Error : "+e);}
    where db1.mdb is the database to be used in application
    find this code working let me ack. at [email protected]

  • Jsp working with and jdbc

    Hi all,
    I am a newbie in this field. My jsp needs to work with jdbc. This code works OK from the local server of my friend but it does not work from my one (IBM Websphere studio application developer 5.1)). I just have this software but I believe my setup is not correct or something like that.
    My code includes:
    try
         DriverManager.registerDriver(new com.sybase.jdbc.SybDriver());
         catch (Exception e)
    e.printStackTrace(System.out);
         try{
              Connection con = DriverManager.getConnection ("jdbc:sybase:Tds:dvc09:2638", "dba", "sql");
    When I run it, the following message comes:
    An error occurred between lines: 13 and 217 in the jsp file: /Test_This.jsp
    Generated servlet error:
    .........\Test_This.java:116: Class com.sybase.jdbc.SybDriver not found.
         DriverManager.registerDriver&#40;new com.sybase.jdbc.SybDriver&#40;&#41;&#41;&#59;
         ^
    Note: ....\Test_This.java uses or overrides a deprecated API. Recompile with "-deprecation" for details.
    1 error, 1 warning
    ]: org.apache.jasper.JasperException: Unable to compile class for JSP
    1 error, 1 warning
    I think I will need to do something with jdbc or so.
    Please help how to overcome this problem.
    Thanks a lot.

    Thanks tolmank and SoulTech2012 for suggestions. However, I modified the codes as recommended by tolmank but problem remains.
    Also, I looked at my local server and it looks like the required files of driver are in place already: the following are present in jdbcdrv: com.sybase.jdbc
    com.sybase.jdbc.resource
    com.sybase.tds
    com.sybase.timedio
    com.sybase.utils
    com.sybase.utils.resource
    All of them are in Libraries Folder.
    But still not working with same error . Pls HELP, as detailed as possible. Thanks a ton.

  • JSP example with database access

    Is there a good example of a JSP portlet doing Oracle database access? Thanks

    David,
    Thanks for the suggestion. We'll schedule that on our list of new sample portlets.
    But as a sidenote, the Database access would really be no different from any standard JDBC calls to connect to and query the database.

  • How to use unload query using JDBC with Informix database

    Hi friends,
    How can i use unload query using JDBC with Informix database?
    When i use it as "unload to 'abc.txt' select * from ........" it gives syntax error.I want to take the data of a table to a file.With dbaccess i can use it but i need to do it using jdbc.
    Thanks,
    Raneesh.

    To the best of my ability to tell, the right way to use this product from within Power Query would be to use its API. Unfortunately, we don't currently support either of the methods needed to be able to authenticate with the service (OAuth 2.0 and a relatively-custom
    digest-based method). Adding a mechanism to allow use of arbitrary OAuth-protected resources is a fairly high priority for us, and I hope we'll be able to deliver something before mid-2015.
    Scraping the website is very hard to do well -- both from an authentication and from a data discovery perspective.

  • How to get the field's type in the database with jdbc?

    How to get the one filed's type(varchar,int,long...etc) with jdbc??
    Can u help me??
    It's best that giving a sample code..

    Thx for your reply,BheegaChicken! But i use it with
    oracle9i jdbc..It doesn't return to my the fields
    type correctly..
    This is problem is caused by oracle jdbc??
    Can u tell me??It depends on the driver classes you are using... some of them don't have an implementation for those methods and you won''t get anything useful. Check the driver documentation.
    ***Annie***

  • Concurrency in Database operations with JDBC

    Sorry for the somewhat ignorant question
    Here it is Are interactions with a database by multiple
    entities on the same db tables managed by the database
    or are they supposed to be managed by the application?
    In specific, additions, commits, and any other write operations...

    To be managed by the application.

Maybe you are looking for

  • Photoshop elements 11 Download Assistant

    I want to download the Adobe Download Assistant for photoshop Elements 11 Trial and the website to do this does not have a "Download" button.  Please help.

  • Reservation Vs.Allocation

    Hello, we are working with Oracle Apps in a WMS inventory org on R11.5.10.2. We have an issue that seems to be a GAP within the Oracle Logisitics footprint and I was wondering if any of you can help with a solution We have sales orders coming from 3

  • How to put checkboxes in a Tree list

    Hi All, I have generated a tree structure in my list from a table. The requirement is I have to put checkboxes for the leaves(bottom most level) of the tree. Now the user will be selecting required leaves and thus my logic will continue. Can anyone t

  • Trouble downloading library ebooks.

    When I attempt to download a public library ebook to my dell notebook with the Adobe Digital Edition 2.0 installed, I get the following Adobe diagnostic:" Adobe Reader could not open (library file) because it is either a not supported file or because

  • Why should we go for ODI?

    Hi, I know the Informatica 9.1.0. Now , I am learning ODI so getting some questions. I am working with the Hyperion & ODI is used with the hyperion to fetch data from any source system. I have few questions in my mind related to ODI. why should I go