Select more than 1 row

hi!
I'm looking for a method that can help me taking out of my database the number of rows I want for each page to be displayed...
...something like select the first 10 rows,
than from 11 to 20 and so on...
...can somebody help me?

Here. Remember to fill in the correct username and password and table and column names in the SQL query.
Hope it helps.
Mel.
import java.sql.*;
public class DatabaseTest
  public static void main(String[] args)
    ResultSet rs = null;
    /** URL of database */
    String URL = "jdbc:mysql://localhost/database_name";
    /** Username used to connect to database */
    String userName = "username";
    /** Password required to connect to database */
    String password = "password";
    /** Database Driver class name */
    String driverName = "org.gjt.mm.mysql.Driver";
    /** SQL Query **/
    String sql = "SELECT * FROM tablename ORDER BY column_name LIMIT 0, 10";
    //Connection
    Connection connection = null;
    boolean isConnected = false;
    //Statement
    Statement statement;
    try
      //Load the driver
      Class.forName(driverName);
      //Connect to the database
      connection = DriverManager.getConnection(URL, userName, password);
      isConnected = true;
    //Catch an error if we couldn't connect
    catch (Exception e)
      System.err.println("Couldn't connect to database. Error: " + e);
      // Kill the connection object
      connection = null;
      isConnected = false;
    try
      //Create a new statement object
      statement = connection.createStatement();
      //Execute the query
      rs = statement.executeQuery(sql);
      if(!rs.next()) System.out.println("No Results found");
       else
         do
           //Print out the results found in the query
           System.out.println("1: " + rs.getString(1));
           System.out.println("2: " + rs.getString(2));
         while(rs.next());
      statement.close();
      connection.close();     
    } //End of try
    catch (Exception e)
      System.err.println(
        "ERROR: Could not connect to database when executing query" + e);
    } //End of catch
}

Similar Messages

  • ALV to select more than one column by row using set_table_for_first_display

    Hello everyone,
    I am developing an application (ALV OO) to select more than 1 column by row ( one ). This is an a holiday application so the idea is:
    -One column will be the day, and the row will be the user.
    So I am trying to select more than one day by user (that would be the row).
    I am using the method set_table_for_first_display but when it shows the alv, doesn't let me to select more than one column with a click of the mouse.
    Does anybody know if I can do this (select more than one column, by row) in somehow?
    Please let me know if you need more clarification about this.
    Thanks in advance
    Diego

    Hi Diego,
    it's all in the documentation.
    set different selection modes through the value of the field u201CSEL_MODEu201D in the layout structure.
    SPACE
    same as 'B'
    see 'B'
    Default setting
    'A'
    Column and row selection
    Multiple columns
    Multiple rows
    The user selects the rows through pushbuttons at the left border of the grid control.
    'B'
    Simple selection, list box
    Multiple columns
    Multiple rows
    'C'
    Multiple selection, list box
    Multiple columns
    Multiple rows
    'D'
    Cell selection
    Multiple columns
    Multiple rows
    Any cells
    The user selects the rows through pushbuttons at the left border of the grid control
    Beyond setting this option, you can set u201CNO_ROWMARKu201D option to hide the mark column which is normally visible when the selection mode allows multiple row selection.
    One point to notice here is that if you set your ALV Grid as to be editable, it may override your selection mode regardless of your layout settings.
    This is from SDN Community Contribution "An Easy Reference for ALV Grid Control" By: Serdar ŞİMŞEKLER
    Sorry, no link,. it's on my disk.
    Regards,
    Clemens

  • How to select more than one row in a JTable swing adf adf?

    how to select more than one row in a JTable swing adf adf?

    // Allow selection to span one contiguous set of rows, visible columns, or block of cells
    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    // Allow multiple selections of rows, visible columns, or cell blocks
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

  • I an getting an error with photo merge in PS cc . It gives me a code tmp00000001 using from photoshop and if I try from bridge it tell me that I need to select more than one image. It is not recognizing the photos I am selecting in bridge. please help. my

    A new problem with CS5 forced me to download PScc but the problem is still there.  I am getting tmp00000001 in photo merge when importing multiple files from inside PS and if trying from bridge I am getting a pop up box telling me I need to select more than 1 file. Photoshop potomerge is not recognizing my selections from bridge..!! please help.. my knowledge of computers is a 3 on a scale of 1-10

    if i run this particular code
    ( SELECT
    AccountDetails.CUSTOMERNUMBER, AccountDetails.ACCOUNTNUMBER, CUSTOMERDETAILS.CDTITLE, CUSTOMERDETAILS.CDFIRSTNAME, CUSTOMERDETAILS.CDLASTNAME, AccountDetails.ACCOUNTTYPE,
    AccountDetails.ORIGINALCONTRACTENDDATE, AccountDetails.CONTRACTTERM, AccountDetails.CONTRACTENDDATE, AccountDetails.BRANCHAREA, AccountDetails.PRODUCTTYPE,
    AccountDetails.HOUSEBANKACCOUNT, AccountDetails.CARMODEL, AccountDetails.CARLICENCE, AccountDetails.ARREARSBALANCE, AccountDetails.CODEBTOR, AccountDetails.GUARANTORNUMBER
    FROM AccountDetails
    JOIN CUSTOMERDETAILS ON AccountDetails.CUSTOMERNUMBER = CUSTOMERDETAILS.CUSTOMERS1
    WHERE EXISTS
    ( SELECT *
    FROM Dcaaccountallocation
    JOIN DebtEpisodes ON DebtEpisodes.ACCOUNTID = Dcaaccountallocation.ACCOUNTID
    WHERE Dcaaccountallocation.dcaid = 41
    AND Dcaaccountallocation.status = 2
    AND DebtEpisodes.DCASentDate IS NULL
    AND Dcaaccountallocation.ACCOUNTID = AccountDetails.ACCOUNTNUMBER
    AND DebtEpisodes.DCAORLAWYER = 'DCA'
    This returns 1 row of data
    However if i run a small part of the above code...
    SELECT *
    FROM Dcaaccountallocation
    JOIN DebtEpisodes ON DebtEpisodes.ACCOUNTID = Dcaaccountallocation.ACCOUNTID
    WHERE Dcaaccountallocation.dcaid = 41
    AND Dcaaccountallocation.status = 2
    It returns a lot of rows with a status of 2
    Now i presume what I am going to do is to ensure that all the fields provide satisfactory requirements, with regards to the above code. Although I have many records in all the stated tables already.
    :(

  • How to select more than one slide on Keynote?

    Please, someone knows how to select more than one slide on keynote for IPad?

    // Allow selection to span one contiguous set of rows, visible columns, or block of cells
    table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    // Allow multiple selections of rows, visible columns, or cell blocks
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

  • How to select more than one free characteristics in web report?

    Hi,
    From the performance point of view, I want to select more than one free characteristics to be displayed in WEB report.
    I know in BEx Analyzer, we can do this by right mouse click and choose' query property' from the context menu, all the free characteristics are displayed in the popup window. But in WEB report these free char don't displayed in the 'query property' popup window.
    Could anyone tell me how to implement this in WEB report?
    Eileen

    Hi,
    each free characteristics in the list has two functions beside it, 'drilldown in rows' and 'drilldown in columns', but this functions as select only one free characteristics, each time you select one, the report will be loaded again.
    if I want to select like 10 free characteristics, the report will be refreshed and reloaded 10 times.
    my question is that how can I select these 10 free characteristics once to improve the performance.
    your help will be appreciated. Thanks.
    Eileen

  • How can i select more than one record in a LOV

    I want to select more than one record in a LOV and put them together before to display them in an item.

    This is not possible with a default LOV, so you'll need to create your own. There are a number of ways to select multiple records:
    a) you can use a tree and set Multi-Selection to Yes
    2) you can use a normal block with a checkbox on each row for the user to select records
    three) with the [SYSTEM.MOUSE_BUTTON_MODIFIERS|http://www.oracle.com/webapps/online-help/forms/10g/topics/designing_forms/mouse/at0604.html?tp=true] variable you can allow users to ctrl+click to select many records in a block. set the background colour to indicate a record has been selected
    iv) there is a pjc in the [demo code section|http://download.oracle.com/otndocs/demos/Forms_Demos_10gr2.zip] which lets you select many rows in a poplist

  • Selecting more than one email to delete

    Has anyone figured out how to select more than one email when deleting? Thanks. Love my phone

    The quickest way, especially if you are deleting bunches of them in a row is to do this...
    open one email. If you want to trash it, click on the trash can icon at the bottom, it trashes it and goes to the next one. As far as skipping the ones you want to save, dunno which way that runs. I just delete all mine since I don't have the Iphone to clear the mail server, I still get it on my desktop computer later.

  • How do I select more than one email address on a Contacts card. I did it before but trouble with Yosemite

    Cannot select more than one email address at a time from Contacts. Before I upgraded to Yosemite, I could view all mail addresses in "All Contacts" and select multiple or single email addresses by "command and tap" for mail. Now I have to open each card and select one address at a time. I don't want to create groups just want to select the addresses I need at the time.

    i dont pay for hosting at all.. i just pay every two years to keep my domain name and with that i get free email forwarding and web forwarding... so i can create email addresses but need to forward them to somewhere else...
    i forward them to one of the POP3 email addresses i was given by my ISP...
    in entourage i set up two email accounts on the one identity so i can send email from the ISPs email or from my domain name email... now if someone sends me an email to my domain name email i get it twice... it only does this on my new mac though, it didnt do it on my old one...
    if i stop forwarding my emails then where will they go? i dont think ill get them, will i?
    very confused!
    Message was edited by: wob

  • How do I select more than one frame? (editing a movie in PS)

    Fisrt time ive tried this.
    I want to do a quick selecton on a movie clip but can only seem to select 1 fram at a time. How can I select more than one frame?
    cheers
    jamie

    If you used Sequence to Layers, Shift and Control key in the layers palette work just as they would when selecting files in Explorer... If it's a video layer, then you should only see one layer and will have to use the Timeline to navigate.
    Mylenium

  • When printing a list in Address Book, how can I select more than the default Attributes and keep them selected when I print again? I want to print ALL information for contacts so I have email address, notes, phone, company, title, etc all on one page.

    When printing a list in Address Book, how can I select more than the default Attributes and keep them selected when I print again? I want to print ALL information for contacts so I have email address, notes, phone, company, title, etc all on one page. I don't want to have to check off an additional 5 or 6 attributes each time I print out contact information. Is there a way to change the default setting for printing lists, so it is not just "phone," "photo," and "job title?"

    I have a user who wants to do this same thing. I did not find any way either to default the attributes to anything other than what you see the first time. Seems like such a trivial thing, hard to believe they do not allow it. I did find a program for this called iDress but I can't seem to download it from any links on the Internet. Not sure if it is free or not, but it was recommended by a link on the Mac support site.

  • How can I select more than one song from the search results?

    I want to create playlists based on certain words in the song title. For example, I may want to create a playlist of all my songs with LOVE in the title.
    Doing the search is easy, but I can't select more than one song at a time. Is there any way in iTunes 12 for Windows to do this? I found an answer in iTunes for Mac, and it basically says to "un-check "Search Entire Library." " but I don't see that option in iTunes for Windows.
    Here is the link to that question: how can i select more than one song from drop down search bar
    I hope some Windows user can help me out.

    Found the "Search Entire Library" option - click on the small (VERY small for my eyesight) down arrow next to the magnifying glass. Also need to select "Filter by: Songs", and then the songs in the main window show the results.
    I'm going to leave this up on the board because 1) in case someone else has this question, and 2) I don't know how to delete it anyway.

  • How can i select more than one song from drop down search bar

    sometimes to make a playlist i will search my music library for a word & then add all the songs with that word in the title
    the drop down search bar will not allow me to select more than one song
    or
    will it?  & i just can't suss out how... maybe you know?
    if so, please tell me~!!!
    thank you

    hey i tried that before i posted this question... i tried all of the normal ways one would use to select more than one item...
    any click of any kind at all takes you out of the search drop down & into the main itunes window... where you are deposited back into the songs alphabetically... no longer are you seeing the results of the search...
    sigh
    at the risk of sounding like one of those people, the "old" itunes did not have this problem...
    grrrr... it seems to be that pesky drop down menu~ if only you could see the search results in the main list as opposed to only in the drop down thing

  • How can we select more than one item from LOV in Query_Find form?

    Hi,
    I have a requirement i.e i want to select more than one customer number seperated by comma from the customer number lov field in the query_find form.How can we write the code for this requirement?
    and after clicking find it has to display notification form which contains the details of customer which you selected from Custome query_find form.
    Could you please help me out.
    Thanks in Advance,
    Dhana

    Found the "Search Entire Library" option - click on the small (VERY small for my eyesight) down arrow next to the magnifying glass. Also need to select "Filter by: Songs", and then the songs in the main window show the results.
    I'm going to leave this up on the board because 1) in case someone else has this question, and 2) I don't know how to delete it anyway.

  • Can I select more than one photo in pages?

    Can I select more than one photo at the same time ipages?

    Yes.
    Touch and hold on one object > tap other objects to select them too.
    This and many other operations are explained in detail in the Pages Help File found in:
    Pages > Tools Menu (wrench) > Help

  • Issue selecting more than one photo

    Anyone else having an issue selecting more than one photo at a time in the iPhoto Library. I want to send a whole batch of birthday photos to my sister and I'm forced to send one photo at a time.
    Holding neither the shift or Command key while I click a photo does nthing. This is a new issue. I didn't used to have this problem
    iPhoto 4.0.3

    Quit iPhoto. Try moving the "com.apple.iPhoto.plist" file from your user's "Library >Preferences" folder to the trash. Try iPhoto again.

Maybe you are looking for

  • How to tell if you have OEM 12c BP1 installed?

    I had OEM 12c installed and attempted to download/apply the Solaris OEM agent software. I ran into the "Below host metric patches are not applied to OMS." error. I discovered this was because I needed BP1. After 3 days of trying to uninstall OEM, fin

  • Progress bar indeterminate state

    is there any way to put the progress bar into indeterminate state ? There are times when my program reaches a certain subroutine that I can not tell ahead how long is the maximum bound is going to be ...there has to be a way to do this easily but I j

  • How do you create a scrolling banner in Dreamweaver CS4?

    How do you create a scrolling banner/marquee in DreamWeaver 4?  I can't find anything about scrolling banners in the documentation or in the several books I've searched.  Thanks.

  • Samba print$ share for windows "point and print"?!

    Howdy, I used to have a print$ share set up, as described [in a post by Rich White|http://discussions.apple.com/thread.jspa?messageID=5572602#5572602] It worked wonderfully well, and all my windows users could get drivers directly off of the server.

  • Time machine is backing up but can't go back in time.

    I started using time machine this morning on my MB Pro. It has about 5 backups listed. Only problem is, when I click the time machine icon, it only shows the first screen and will not go back. The timeline on the right only shows now. It's not going