Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7766139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:20:12+00:00 2026-06-01T15:20:12+00:00

I have this Java code which is used for JSF pagination: public List<ActiveSessionObj> list(int

  • 0

I have this Java code which is used for JSF pagination:

public List<ActiveSessionObj> list(int firstRow, int rowCount, String sortField, boolean sortAscending) throws Exception {

        String SQL_LIST_BY_ORDER_AND_LIMIT = "SELECT * FROM ACTIVESESSIONSLOG ORDER BY ? ? LIMIT ?, ?";



        if (ds == null) {
            throw new SQLException();
        }

        String sortDirection = sortAscending ? "ASC" : "DESC";
        String sql = String.format(SQL_LIST_BY_ORDER_AND_LIMIT, sortField, sortDirection);
        Connection conn = ds.getConnection();
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;
        List<ActiveSessionObj> dataList = new ArrayList<ActiveSessionObj>();

        try {
            conn.setAutoCommit(false);
            boolean committed = false;
            preparedStatement = conn.prepareStatement(sql);
            preparedStatement.setString(1, sortField);
            preparedStatement.setString(2, sortDirection);
            preparedStatement.setInt(3, firstRow);
            preparedStatement.setInt(4, rowCount);

            resultSet = preparedStatement.executeQuery();
            /* take the result from the SQL query and insert it into Array List collection */
            dataList = ActiveSessionsArrayList(resultSet);

        } catch (SQLException e) {
            throw new Exception(e);
        } finally {
            conn.close();
        }

        return dataList;
    }

I use this SQL statement to generate ArrayList:

SELECT * FROM ACTIVESESSIONSLOG ORDER BY ? ? LIMIT ?, ?

Can this SQL query be used for Oracle? Or this is MySQL specific?

Best wishes

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:20:14+00:00Added an answer on June 1, 2026 at 3:20 pm
    Case1: If you want first `twenty Records` only then 
    
     select * from ( 
         select rn,a.*
         from Activesessionlogs a
         order by ??)
     where rn <=20
     order by rn
    
    Case2:If you want the record between `5 to 10` then
    
    select * from (
    select rownum rn,e.* from Activesessionlogs e order by ??)
    where rn >=5 and rn<=10 
    order by rn 
    

    Eg:
    Lets find an example below

    select * from (
    select rownum rn,e.* from emp e order by hiredate)
    where rn >=5 and rn<=10
    order by rn asc
    

    output

    Note :Rownum> or rownum>= will not work in the same query .A very good blog explaining this Oracle Rownum

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some Java code which looks roughly like this: String urlString = ftp://polar.ncep.noaa.gov/pub/history/waves/multi_1.glo_30m.dp.200601.grb2;
I have a jsp page which needs a java code. This java code inside
In our application, I have seen code written like this: User.java (User entity) public
I have this java code which is a part of a managed bean which
I have a Tomcat application server and this Java source code: public class MyServlet
I have java code snippets dynamically generated which refer back to classes with public
I have this java code: <script src=http://www.google.com/jsapi></script> <script type=text/javascript> google.load(jquery, 1.2.6); $(a#more).click(function() { $(#info_box).show(blind,
I have this Java code, and I want to do the same thing in
i have a question , i have this timer code in java that when
I am using iTextSharp in VB.net. I have this piece of code from java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.