Retrieve all data on textArea question ---please help

hi, I am writing a program that will retrieve all data from Access to JTextArea. For example, DB has 10 records and I would like to show all 10 records at once on JTextArea. However, in my code, i can retrieve the last records only. The following is part of my code, please help me to clear my thought. I think i got the idea about loop but dunno how to do. thanks.
//the data access class about sql query
public static String retrieve() throws SQLException
String query = "SELECT ClockIn, ClockOut FROM TimeCard";
Statement statement = connection.createStatement();
ResultSet r = statement.executeQuery(query);
String t3 = null;
while(r.next())
String t1 = r.getString(1);
String t2 = r.getString(2);
t3 = t1 + " " + t2 + "\n";
statement.close();
return t3;
//the JTextArea class
public void performUserDisplay()
testTime tTime = new testTime();
try
testTime.connect();
message.setText(tTime.retrieve()); //*** i think here has the problem too but i have no idea what to do
testTime.disconnect();
catch(Exception e)
System.out.println("Exception");
I know maybe i should use message.append() but still, I am sort of new to java, so i don't really know how to do it.
Please help me and thanks in advance

Change
String t3 = null;
while(r.next())
String t1 = r.getString(1);
String t2 = r.getString(2);
t3 = t1 + " " + t2 + "\n";
statement.close();
return t3;
...to
StringBuffer res = new StringBuffer();
while(r.next())
    res.append(r.getString(1)).append(" ").append(r.getString(2)).append("\n");
statement.close();
return res.toString();

Similar Messages

  • I bought iPhone 4 for my wife, didn't create a separate apple ID account for her at that time. How can I now create a new one for her, sync her phone to the same PC that I sync my iPhone with without loosing all of her data, contacts, etc. Please help!

    I bought iPhone 4 for my wife, didn't create a separate apple ID account for her at that time. How can I now create a new one for her, sync her phone to the same PC that I sync my iPhone with without loosing all of her data, contacts, etc. Please help!

    I bought iPhone 4 for my wife, didn't create a separate apple ID account for her at that time. How can I now create a new one for her, sync her phone to the same PC that I sync my iPhone with without loosing all of her data, contacts, etc. Please help!

  • HT1338 I have a Mac OS X Version 10.5.8. Just updated my iphone 5 & can not back anything up from itunes because my software on my mac is not up to date. What software should I now have to be up to date? Im so confused by all that is offered! PLEASE HELP

    I have a Mac OS X Version 10.5.8. Just updated my iphone 5 & can not back anything up from itunes because my software on my mac is not up to date. What software should I now have to be up to date? Im so confused by all that is offered! PLEASE HELP ME.

    Hi
    You need to upgrade to the next OS 10.6 Snow Leopard by purchasing the DVD online.
    http://store.apple.com/us/product/MC573Z/A/mac-os-x-106-snow-leopard
    and once installed, use Software Update
    - to update to 10.6.8
    - and update your iTunes.

  • How do i deactivate the auto updation on my iphone 4,i want to use only watsapp but when i am turning on my celleular data all apps starts updating theirself,please help me

    how do i deactivate the auto updation on my iphone 4,i want to use only watsapp but when i am turning on my celleular data all apps starts updating theirself,please help me.I am not using any internet pack other than watsapp.

    iPhone do not do automatic update. You have to manually trigger the updates.
    If your Settings > iTunes & App Stores > Automatic Downloads > Music, Apps, Books are ON then when you purchase any new content/item with any devices/computer iTunes, it will automatically download. Switch it OFF if you do not want that to happen.

  • I want to change my apple id password but I forgot the security questions please help me some using my icloud I'd

    I want to change my apple id password but I forgot the security questions please help me some using my icloud I'd and if confirmation is must so please phone number is mine please send a code please help me my apple

    Welcome to the Apple community.
    If you are unable to remember your password, security questions, don’t have access to your rescue address or are unable to reset your password for whatever reason, your only option is to contact AppleCare, upon speaking to an operator you should explain that your problem is related to your Apple ID, this way you will not be charged for assistance, even if you don’t have an AppleCare plan.
    The operator will take you through some steps you may have already tried, however they need to be sure they have exhausted all usual approaches before trying to reset your account, so you should try to be helpful and show patience with the procedure.
    The operator will need to verify they are speaking to the account holder and may ask you some questions that only the account holder could know, and you will need to answer them if the process is to proceed.
    Once the operator has verified your identity they will send a message through to your device which contains an alpha numeric code, which you will need to read back to them.
    Once this has been completed they will send an email to your iCloud email address after a period of 24 hours, so you should check that mail is enabled in your devices iCloud settings.
    Upon receipt of the email, use the reset link provided to reset your password, after which you should be able to make the adjustments to iCloud that you wish to do.

  • My macbook crashed about two weeks ago and I had icloud already set up. How do I go about retrieving the music and images? Please, help me. I had over 10gb of music on that computer and the only place it was backup was icloud. Thanks.

    My macbook crashed about two weeks ago and I had icloud already set up. How do I go about retrieving the music and images? Please, help me. I had over 10gb of music on that computer and the only place it was backup was icloud. Thanks.

    I hate to say this, but unless you are paying the 25 bucks you cannot back up your library to the cloud.
    All you can do is back up the items you "purchased" from Apple.
    iTunes Match
    For $24.99/year you’ll get access to all your iTunesmusic including tunes you ripped from CDs or “borrowed” from anonymous friends. It scans your library to see if the song exists in iTunes’ 18 million song catalog and if it does it’ll stream it to you at 256 kbps. If your song is not in iTunes then it’ll be uploaded to iCloud at whatever rate it is on your device where it can be streamed for your listening pleasure. I cannot find any information on how to restore a library, however
    Best of luck

  • I was hacked i kept getting emails that some purshcaes were being made when no one was downloading them and i guess they hacked my apple iD because they changed the security question and now i cant change anything without the security question please help

    I was hacked i kept getting emails that some purshcaes were being made when no one was downloading them and i guess they hacked my apple iD because they changed the security question and now i cant change anything without the security question please help i want to reset the security question but i cant.

    You should contact Apple by phone as soon as possible. You'll need to change your Apple ID and all passwords.
    See Contact Apple at the bottom right of this page.
    Hope this helps.

  • Hi I live in Iran and I forgot the answer to the security question please help me thanks

    Hi I live in Iran and I forgot the answer to the security question please help me thanks

    How to reset your Apple ID security questions.
    Go to appleid.apple.com, click on the blue button that says 'Manage Your Apple ID'.
    Log in with your Apple ID and password. (If you have forgotten your Apple ID password, go to iforgot.apple.com first to reset your password with a password recovery email)
    Go to the Password & Security section on the left side, and click on the link underneath the security questions that says 'Forgot your answers? Send reset security info email to [email]'.
    This will generate an automated e-mail that will allow you to reset your security questions.
    If that doesn't work, or  there is no rescue email link available, then click on 'Temporary Support PIN' that is in the bottom left side, and generate a 4-digit PIN for the Apple Account Security Advisor you will be contacting later.
    Next, go to https://getsupport.apple.com
    (If you see a message that says 'There are no products registered to this Apple ID, simply click on 'See all products and services')
    Choose 'More Products & Services', then 'Apple ID'.
    A new page will open.
    Choose 'Other Apple ID Topics', then 'Forgotten Apple ID Security Questions'.
    Click the blue 'Continue' button.
    Select the contact option that suits your needs best.

  • I have had a reinstall nightmare getting my loops back they are in the apple library, I can access them through the media browser but I only have a few available through the loop browser, how do I get them all back there again? please help

    I have had a reinstall nightmare getting my loops back they are in the apple library, I can access them through the media browser but I only have a few available through the loop browser, how do I get them all back there again? please help

    "Where do I find my hundreds of dollars of downloads I have done since 2005?"
    They will only be where you put them  If you are doing the very basics, then they will be on your computer and they will be in your backup copy of your computer.
    The itunes store is not global at all, never has been. You cannot redownload your content from another country.  You can only use the countrys itunes store for the country that you are physically located.

  • HT2968 I can not update several of my apps that i have purchased a while back in my Apps Store on my MacPro. Because it keeps using my old @me account for iTunes and i don't remember the password or security question, Please help?

    I can not update several of my apps that i have purchased a while back in my Apps Store on my MacPro. Because it keeps using my old @me account for iTunes and i don't remember the password or security question, Please help?

    Hi AlphaCentori,
    If you are having issues accessing the Apple ID that was used to originally purchase those apps, you may find the following article helpful:
    Apple Support: Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/ht5312
    Regards,
    - Brenden

  • Help!! I just updated my iPad 2 into IOS 5.1.1.. When it finished updating, I can't open all of my games. Please help me fix this. :( thank you.

    Help!! I just updated my iPad 2 into IOS 5.1.1.. When it finished updating, I can't open all of my games. Please help me fix this. :( thank you.

    You are most welcome

  • Adobe flash CS6 crashes when using the type tool or Editing word all the time... please help!

    Adobe flash CS6 crashes when using the type tool or Editing word all the time... please help!

    Nobody can tell you anything without proper system info or other technical details. The standard answer with all text issues simply is, that you have a "bad font" on your system and need to get rid of it.
    Mylenium

  • I need to pass a query in form of string to DBMS_XMLQUERY.GETXML package...the parameters to the query are date and varchar ..please help me..

    I need to pass a query in form of string to DBMS_XMLQUERY.GETXML package...the parameters to the query are date and varchar ..please help me build the string .Below is the query and the out put. ( the string is building fine except the parameters are with out quotes)
    here is the procedure
    create or replace
    procedure temp(
        P_MTR_ID VARCHAR2,
        P_FROM_DATE    IN DATE ,
        P_THROUGH_DATE IN DATE ) AS
        L_XML CLOB;
        l_query VARCHAR2(2000);
    BEGIN
    l_query:=  'SELECT
        a.s_datetime DATETIME,
        a.downdate Ending_date,
        a.downtime Ending_time,
        TO_CHAR(ROUND(a.downusage,3),''9999999.000'') kWh_Usage,
        TO_CHAR(ROUND(a.downcost,2),''$9,999,999.00'') kWh_cost,
        TO_CHAR(ROUND(B.DOWNUSAGE,3),''9999999.000'') KVARH
      FROM
        (SELECT s_datetime + .000011574 s_datetime,
          TO_CHAR(S_DATETIME ,''mm/dd/yyyy'') DOWNDATE,
          DECODE(TO_CHAR(s_datetime+.000011574 ,''hh24:'
          ||'mi''), ''00:'
          ||'00'',''24:'
          ||'00'', TO_CHAR(s_datetime+.000011574,''hh24:'
          ||'mi'')) downtime,
          s_usage downusage,
          s_cost downcost
        FROM summary_qtrhour
        WHERE s_mtrid = '
        ||P_MTR_ID||
       ' AND s_mtrch   = ''1''
        AND s_datetime BETWEEN TO_DATE('
        ||P_FROM_DATE||
        ',''DD-MON-YY'') AND (TO_DATE('
        ||P_THROUGH_DATE||
        ',''DD-MON-YY'') + 1)
        ) a,
        (SELECT s_datetime + .000011574 s_datetime,
          s_usage downusage
        FROM summary_qtrhour
        WHERE s_mtrid = '
        ||P_MTR_ID||
        ' AND s_mtrch   = ''2''
        AND s_datetime BETWEEN TO_DATE('
        ||P_FROM_DATE||
        ',''DD-MON-YY'') AND (TO_DATE('
        ||P_THROUGH_DATE||
        ','' DD-MON-YY'') + 1)
        ) B
      where a.S_DATETIME = B.S_DATETIME(+)';
    SELECT DBMS_XMLQUERY.GETXML('L_QUERY') INTO L_XML   FROM DUAL;
    INSERT INTO NK VALUES (L_XML);
    DBMS_OUTPUT.PUT_LINE('L_QUERY IS :'||L_QUERY);
    END;
    OUTPUT parameters are in bold (the issue is they are coming without single quotes otherwise th equery is fine
    L_QUERY IS :SELECT
        a.s_datetime DATETIME,
        a.downdate Ending_date,
        a.downtime Ending_time,
        TO_CHAR(ROUND(a.downusage,3),'9999999.000') kWh_Usage,
        TO_CHAR(ROUND(a.downcost,2),'$9,999,999.00') kWh_cost,
        TO_CHAR(ROUND(B.DOWNUSAGE,3),'9999999.000') KVARH
      FROM
        (SELECT s_datetime + .000011574 s_datetime,
          TO_CHAR(S_DATETIME ,'mm/dd/yyyy') DOWNDATE,
          DECODE(TO_CHAR(s_datetime+.000011574 ,'hh24:mi'), '00:00','24:00', TO_CHAR(s_datetime+.000011574,'hh24:mi')) downtime,
          s_usage downusage,
          s_cost downcost
        FROM summary_qtrhour
        WHERE s_mtrid = N3165 AND s_mtrch   = '1'
        AND s_datetime BETWEEN TO_DATE(01-JAN-13,'DD-MON-YY') AND (TO_DATE(31-JAN-13,'DD-MON-YY') + 1)
        ) a,
        (SELECT s_datetime + .000011574 s_datetime,
          s_usage downusage
        FROM summary_qtrhour
        WHERE s_mtrid = N3165 AND s_mtrch   = '2'
        AND s_datetime BETWEEN TO_DATE(01-JAN-13,'DD-MON-YY') AND (TO_DATE(31-JAN-13,' DD-MON-YY') + 1)
        ) B
      where a.S_DATETIME = B.S_DATETIME(+)

    The correct way to handle this is to use bind variables.
    And use DBMS_XMLGEN instead of DBMS_XMLQUERY :
    create or replace procedure temp (
      p_mtr_id       in varchar2
    , p_from_date    in date
    , p_through_date in date
    is
      l_xml   CLOB;
      l_query VARCHAR2(2000);
      l_ctx   dbms_xmlgen.ctxHandle;
    begin
      l_query:=  'SELECT
        a.s_datetime DATETIME,
        a.downdate Ending_date,
        a.downtime Ending_time,
        TO_CHAR(ROUND(a.downusage,3),''9999999.000'') kWh_Usage,
        TO_CHAR(ROUND(a.downcost,2),''$9,999,999.00'') kWh_cost,
        TO_CHAR(ROUND(B.DOWNUSAGE,3),''9999999.000'') KVARH
      FROM
        (SELECT s_datetime + .000011574 s_datetime,
          TO_CHAR(S_DATETIME ,''mm/dd/yyyy'') DOWNDATE,
          DECODE(TO_CHAR(s_datetime+.000011574 ,''hh24:'
          ||'mi''), ''00:'
          ||'00'',''24:'
          ||'00'', TO_CHAR(s_datetime+.000011574,''hh24:'
          ||'mi'')) downtime,
          s_usage downusage,
          s_cost downcost
        FROM summary_qtrhour
        WHERE s_mtrid = :P_MTR_ID
        AND s_mtrch   = ''1''
        AND s_datetime BETWEEN TO_DATE(:P_FROM_DATE,''DD-MON-YY'')
                           AND (TO_DATE(:P_THROUGH_DATE,''DD-MON-YY'') + 1)
        ) a,
        (SELECT s_datetime + .000011574 s_datetime,
          s_usage downusage
        FROM summary_qtrhour
        WHERE s_mtrid = :P_MTR_ID
        AND s_mtrch   = ''2''
        AND s_datetime BETWEEN TO_DATE(:P_FROM_DATE,''DD-MON-YY'')
                           AND (TO_DATE(:P_THROUGH_DATE,'' DD-MON-YY'') + 1)
        ) B
      where a.S_DATETIME = B.S_DATETIME(+)';
      l_ctx := dbms_xmlgen.newContext(l_query);
      dbms_xmlgen.setBindValue(l_ctx, 'P_MTR_ID', p_mtr_id);
      dbms_xmlgen.setBindValue(l_ctx, 'P_FROM_DATE', to_char(p_from_date, 'DD-MON-YY'));
      dbms_xmlgen.setBindValue(l_ctx, 'P_THROUGH_DATE', to_char(p_through_date, 'DD-MON-YY'));
      l_xml := dbms_xmlgen.getXML(l_ctx);
      dbms_xmlgen.closeContext(l_ctx);
      insert into nk values (l_xml);
    end;

  • I dont remember the first apple id that link with my clash of clans apps. the problem now is i need to link my COC village and it keep saying "please log in with correct game center" is there anyway that i can retrieve my old apple id? please help me

    i dont remember the first apple id that link with my clash of clans apps. the problem now is i need to link my COC village and it keep saying "please log in with correct game center" is there anyway that i can retrieve my old apple id? please help me i dont want to lose my village, i have spent my money on that game to much. hmmm

    thanks mate, but the problem is im using different apple id now, and after about 1 year play coc and today i want to link the village , suddenly coc said that
    thats mean im playing this village with different apple id and it not saved. and the problem is i dont remember the first apple id and password that i use first time to download this game. hmmm it was so confusing, why coc and game center just make this thing saved with a new game center account.

  • How to retrieve all datas that lost when i update my iphone4 to that 6.10 ios. i tried to look at may i tunes in my computer but it seems that i forgot to perform back ups since i purchased this phone 2yirs ago.. pls send me an advice..thank u.

    how to retrieve all datas that lost when i update my iphone4 to that 6.10 ios. i tried to look at may i tunes in my computer but it seems that i forgot to perform back ups since i purchased this phone 2yirs ago.. pls send me an advice..thank u.

    All of the data should be on your computer, simply sync it back.
    If the update was done via iTunes on the computer, the first step in the process is a backup of the device.

Maybe you are looking for

  • PROBLEM with 24/96 bit-rate USB DAC that worked fine until I plugged in two

    I'm using a late 2008 15" Macbook Pro that I bought Jan 2009 right before the SD card models came out. Mac OSX 10.6.4 and iTunes 9.2 are installed. I have a Nuforce Icon HDP and a CEntrance DACport 24/96 bit-rate USB DAC (external sound cards) that s

  • Cisco RM-1252G-A-K9 can't access web interface

    I hope I am in the correct forum for this topic? For some reason I cannot access the web interface in order to configure this device. I have it connected to a router (DHCP). The router assigns an IP Address and I can ping it. If I attempt to go to th

  • Displaying Image In JSP for Mozilla Browser

    Hai all How to display the .gif image in JSP file using Mozilla browser

  • IPhoto library compression

    I just deleted an event from iPhoto: deleted the event, deleted the slideshow that contained the images and emptied the trash. I then noticed that the library size was reduced by .9 gig yet, the folder with the original pics was 1.47 gig in size. I q

  • Web form User Control

    Hello all, I have created a simple web page with 4 cascading dropdowns that pulls its data from a web service and it is functioning nicely.  I will probably need this functionality on a few different pages so I thought it might make sense to encapsul