Why can't I print the content of a row in the ResultSet twice?

An exception was thrown when I tried to print it twice like this:
while (rs.next()) {
System.out.println(rs.getString(1));
System.out.println(rs.getString(1));
}Why?

An exception was thrown when I tried to print it
twice like this:
while (rs.next()) {
System.out.println(rs.getString(1));
System.out.println(rs.getString(1));
}Why?The real question is: why would you want to do that? ResultSets shouldn't be printed like that. MVC separation says that printing is View, and ResultSet is persistence. Better to iteration through the ResultSet once, loading the data into an object or data structure, close the ResultSet in a finally block, and then pass the object or data structure for rendering (be that printing or JSP or Swing or whatever your View is).
%

Similar Messages

  • Why can't i print the e-book that i purchased?

    why can't i print the e-book that i purchased?

    The print permission might not be available for that book. In Library mode, right click on the book and select Item Info. Verify whether book had print permission.
    These permissions are set at the server level by the distributor.

  • Why can i only print current frame in an email?

    Why can I only print the current frame of an email?

    Sophie Hubble which Adobe software or service is your inquiry in reference too?

  • When I click on a link from a web page opened in Safari I get a blank black screen. Why can't I see the contents of the page?

    When I click on a link from a web page opened in Safari I get a blank black screen. Why can't I see the contents of the page?

    Is this any link in any page, or one particular link in a particular page?

  • Why can't I get the Kodak Document Print App in the UK?

    Why can't I get the Kodak Document Print App in the UK?

    "Apparently it's available in the US iTunes store but not here?"
    Because Kodak has chosen not to make it available there.
    "Can't for the life of me understand why that should be!"
    You do not have to understand it for it to be so.
    You can try asking Kodak, as they make the app.

  • I have an iPhone 4S.  When I try to print pictures, from my Windows computer, it doesn't work.  Open Office also gives me an "unknown graphic" message.  These are JPEGs, aren't they?  Why can't I print and what is the unknown graphic?

    I have an iPhone 4S.  When I try to print pictures, from my Windows computer, it doesn't work.  Open Office also gives me an "unknown graphic" message.  These are JPEGs, aren't they?  Why can't I print and what is the unknown graphic?

    Hi,
    "A day after the name change became official my built in skydrive app stopped working"
    Did you point that SkyDrive changed to OneDrive?
    Did you move your OneDrive to another location or change its name?
    Please login OneDrive with web-based to check if you could access it successfully.
    Please refer to the following article to try the troubleshooter and check the service status:
    SkyDrive: FAQ
    http://windows.microsoft.com/en-in/windows-8/skydrive-app-faq
    Karen Hu
    TechNet Community Support

  • Why can't I print from my Mac book Pro to my HP Deskjet 3054A.  I am currently able to print wirelessly from my old PC desk top but not the laptop

    Why can't I print from my Mac book Pro to my HP Deskjet 3054A.  I am currently able to print wirelessly from my old PC desk top but not the laptop

    I am running Mac OS X Lion 10.7.3.  I believe I have the lastes drivers.  I bought the laptop and got the printer free with it in December.  I was initially able to print from the laptop but now says there is no connection. 

  • HT204088 Why can't I see the purchase history from the ipad? I mean, I can buy apps and in game content directly from my iPad, but I have have to install iTunes on my PC to see the purchase history? What kind of deal is that?

    Why can't I see the purchase history from the ipad? I mean, I can buy apps and in game content directly from my iPad, but I have have to install iTunes on my PC to see the purchase history? What kind of deal is that?

    Welcome to Apple Communities
    You don't need to install iTunes for the purchase history. You can see it in your iPad (iTunes > Purchased), but you need to install it if you want the order numbers

  • Why can't I change the content for some songs when I click the Get Info button?

    Why can't I change the content for some songs when I click the Get Info button?  The information on the song, artist, genre is grayed out and will not allow me to alter the information.

    Hi htechadmin,
    Revcevied your PM and noted all details, Many Thanks.
    Getting this addressed by the team, either they will reply to you, here, or they shall email Or Call you.
    Regards,
    LP

  • Why can't I print a document from iphone5 to hp wireless printer?

    Why can't I print a document from iphone5 to hp wireless printer?

    Try the following steps.
    Power off the printer.
    Reset the phone by holding the sleep/wake and home buttons together until you see the Apple logo and then release. The phone will reboot.
    Power cycle your router. Disconnect it from power for about 30 seconds and then power it back on.
    Once it has completed the reboot, then power the printer back on and make sure it connects to the wi-fi network
    Open the content on the phone that you want to print and attempt printing it again.
    If that does not do it, then check to see if there is any newer firmware for the printer from HP.

  • Why can't I print a pdf from my mac pro to my printer?

    why can't I print a pdf from my mac pro to my printer?

    Don't know! You'll have to give us more details of what's happening when you try. Can you print other documents OK? When you try to print, does the printer icon appear in the dock - click on it and see if there are any printer messages.
    Matt

  • Why can I not print a PDF from an email?

    Why can I not print a PDF from an email any longer?

    Can you explain in better detail?
    Is it when you open the file attachment and attempt to Print?
    Is it right-mouse clicking and attempting to Print?
    Is it when you print the email itself and expect the attachment to Print?

  • Why can't I print from my ipad?

    I've had my iPad for almost a year now and I like it a lot. It looks very good, it performs very well even though I'm far from reaching my goal of only taking my ipad to school, nothing else.
    One important reason why this won't be the case for quite a while still is that I can't print from the iPad.
    Let me explain. I make quite a number of worksheets. Being a teacher this is one of the things you do so that the students have something to write on and do exercises. Over the years there have been many of these and my initial thought was to put them all on the iPad and print them when needed. But imagine my surprise when I found out that printing from an iPad seems to be near impossible.
    Other colleagues of mine got themselves cheap EEPCs and they work fine. They can access the local printer easily printing whatever they wish. But I can't do that! Unless my school buys a new Air-thingy printer from HP I just won't print there! And that just *****.
    I've bought a sleek and expensive machine that is so sophisticated - that I can't use it the way I want to. And that isn't even ******** about the file system that seems to be equally messed up.
    My question is, why can't I print from the iPad? Printing had been announced many times before the launch of iOS 4 and then, all of a sudden, nothing more. How can this be? Why do I have to buy additional software - which is not really cheap and far from certain to work at all - just to be able to print a few pages?
    Please help me understand this, as I see it, major flaw of the iPad and iOS 5.

    Thanks guys,
    I seem to have understood by now.
    To sum it up:
    - I can print with the iPad directly if the printer is Airprint compatible.
    - I can print via a number of more or less working apps.
    I've downloaded some HP software for my iPad and even seem to be able to access it from some other apps, that is except Apples Pages app. Sigh! So whenever I have to make changes in my documents, I still can't print.
    GoodReader on the other hand lets me send my documents to the HP app, but the app/HP won't let me print microsoft docs unless I register and send my documents over to HP where the printing prep is being made, then they send it back to me/my printer. Anyway GoodReader blows my layout apart, so I must change it on the iPad, but when I do …
    It's a big catch.
    You must realize that printing really isn't that comfortable and that as a spoiled old Mac user I might be excused for wishing something more workable.
    The truth seems to be that I've got to carry all those docs on a USB-stick, move them over to the Windows-machine at our school and print from there - which is what I do on a daily basis already.
    All those workarounds that may or may not work (check out user comments on those printing apps!) are so annoying that my overall question remains pretty much the same.
    But I could also rephrase the question: Why can't I print from the so-called best tablet office app even if I am equipped with all the apps I apparently need?
    Please understand that this is not Apple-bashing in any way. This is a real problem for me in my everyday life. I won't be persuading my school to buy AirPrint printers just because of my little problem and I honestly don't want to spend more money on printing apps that seem never to even have gone through beta testing.
    Still, thanks for you efforts. I guess I'll just have to wait for Microsoft Office for iPad to get that big problem solved.

  • Why can't i print a pdf file, it's asking for a password and i have no idea what it is it's never asked me before?

    why can't I print a pdf file, it's asking for a password and I have no idea what it is it never asked for one before?

    Good afternoon SaraThanks for responding. Yes, I have been able to open these files before without a password. Funny thing is it is happening on both my husband's laptop as well as mine. I'd appreciate any help you could give me but the file is very personal. So, if you can assist in a way that won't compromise the security I would be grateful for your help.Thanks and have a great day!Kim Morse 

  • Why can't i print a web page,

    why can't i print a web page, using windows vista 64, HP photosmart 8250?

    This software can help print from the web:
    http://h10025.www1.hp.com/ewfrf/wc/document?docnam​e=c01812475&cc=us&dlc=en&lc=en&product=443024&tmp_​...
    This utility can help determine if things may not be setup correctly:
    http://h10025.www1.hp.com/ewfrf/wc/softwareDownloa​dIndex?cc=us&lc=en&jumpid=ex_r4155/hho/ipg/ccdoc/p​...
    007OHMSS
    I was a support engineer for HP.
    If the advice resolved the situation, please mark it as a solution. Thank you.

Maybe you are looking for