• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Resultset

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

How to retrive multyple rows from a data set ...i am getting only last row because of
While(rs.next())
(
Jtextfield1.settext(rs.getString("name"))
jtextfield2.setText(rs.getString("name"))
)
In both text fields I am getting same result .
only last row record just beacuse of while loop

But I want to set 1row and 2 row records respctvly..
What should I do...?
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ResultSets are record-oriented - you can only ever access a single record at a time. You'll need to change your display logic accordingly. Something like:
 
Vineet kumar Gupta
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you tim maroos... It is working
 
Vineet kumar Gupta
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

what is the method of setting records in a jtable....lyk for jtextfield is...
Jtextfield1.setText(rs.getString("name"))..

What will be for jTable.?
What will be the way of retriving records from resultset and placing these on a jtable....

 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "retriving records from resultset" that the code above does not already do? Is this question purely about how to use JTable?
 
Vineet kumar Gupta
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I am a new lerner of java and working on a project..my faculty not helps me..thats why I am here... I even dont know how to use a jtable.... I do not want to create it by coding... I have draged and dropped already a table from palette in netbeans.... Number of rows and columns are same as in sql table ...now I want to show sql table in jtable....
How can I achive this.... guide me...
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to learn something, then don't use a GUI builder like NetBeans. As you discovered, it doesn't help you understand the Swing classes - which in this case you need to. Start here: http://docs.oracle.com/javase/tutorial/ui/index.html
 
Vineet kumar Gupta
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are saying that I should design the project in notepad by coding....? I do not have enough time friend...i hv almost completed it but ...the scenario is ....i hv a table in sql named student...now I hv a button say "view all" by which I want to see all the records of student table.....please guide me..
 
Vineet kumar Gupta
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go to this page I want to use jtable like it...there is a table view

http://docs.oracle.com/javase/tutorial/ui/overview/demo.html
 
Tim Moores
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can write code any way you want; I wouldn't use Notepad, but at a minimum something that understand Java syntax, like Vim. But if you already know NetBeans you might just as well use that. Either way, I don't see how you could get around learning the Swing classes if you want to create an app with a Swing GUI. At the least, rather obviously, you'll need to understand JTable: http://docs.oracle.com/javase/tutorial/uiswing/components/table.html
 
Vineet kumar Gupta
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okk friend...you are right...first I have to know about the jtable ..and.its structure ....thank you for your guideline...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic