Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "resultset" Watch "resultset" New topic
Author

resultset

archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
I am using jdbc connectivity with java....i want to retrieve values of resultset so that i can use these values outside the loop .....please help me...
By using following statement more than one rows are retrieved .....
I want to display different values of a,b,c and d in table in pdf .how can we do this......
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

archana tiwari wrote:please write the code so that my problem can be solved

No. We are NotACodeMill. We will assist you in finding the solution, but we will not write your code for you.

What happens if you move the part that adds these cells inside your while loop?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Rob Spoor wrote:
archana tiwari wrote:please write the code so that my problem can be solved

No. We are NotACodeMill. We will assist you in finding the solution, but we will not write your code for you.

What happens if you move the part that adds these cells inside your while loop?


more than one tables are generated according to the number of times while loop is executing...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19725
    
  20

Then don't add the table creating code to the loop. Instead do this (pseudo code):
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Rob Spoor wrote:Then don't add the table creating code to the loop. Instead do this (pseudo code):



I am not getting what you are trying to say....please tell me in detail.....
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Rob Spoor wrote:Then don't add the table creating code to the loop. Instead do this (pseudo code):


This code is working but underlined part is giving error....in first column i have to print 1,2,3 .but auto increment is not working.what should i do?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42367
    
  64
If you want to print incremental numbers then don't reset i to 1 in each iteration.


Ping & DNS - my free Android networking tools app
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Ulf Dittmer wrote:If you want to print incremental numbers then don't reset i to 1 in each iteration.

but int i is giving error because The method addCell(PdfPCell) in the type PdfPTable is not applicable for the arguments (int).so what should i use?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42367
    
  64
The first thing to do is to move the "int i=1" outside of the loop.
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Ulf Dittmer wrote:The first thing to do is to move the "int i=1" outside of the loop.

I have checked it also .. i have put int i=1 outside the loop
but table.addCell(i); is giving error.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42367
    
  64
There is no method PdfPTable.addCell(int) - what made you think there is? If you want to add the value of i as a string then the easiest way is to construct a String from i and call PdfPTable.addCell(String).
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Ulf Dittmer wrote:There is no method PdfPTable.addCell(int) - what made you think there is? If you want to add the value of i as a string then the easiest way is to construct a String from i and call PdfPTable.addCell(String).


but using string we can not increment it to 1 then 2 then 3 we get 1 then 11 then 111 by concatenating the string.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42367
    
  64
I didn't say you should increment a string, I said you should convert the int to a string when calling the PdfPTable.addCell method.
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Ulf Dittmer wrote:I didn't say you should increment a string, I said you should convert the int to a string when calling the PdfPTable.addCell method.

thanks ...problem is solved....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: resultset