• Post Reply Bookmark Topic Watch Topic
  • New Topic

Populating Database values in to JTable

 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,
How can i insert the Database values into JTable. Please help me with the code. I want to create the headings and also the table contents

Please help me..

regards

Aravind Prasad
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You read the values via JDBC and populate a TableModel for the JTable.
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou for your reply,
I've statically defined the number of rows as 100, Now when i search the records corresponding to a particular date, then it is displaying.

for egs :
from = 01-01-2007
to = 15-01-2007
query = "select * from table where date_in >= '01-01-2007' and date_in<='15-01-2007' ";

when i search this, I will be getting 30 records which I can see it properly.

But when i give the from date = 01-01-2006
I've 200 records which I cannot see!
Please help to sort this out ranchers

thanks in advance

regards

Aravind Prasad
 
Paul Clapham
Sheriff
Posts: 21889
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've statically defined the number of rows as 100
And so 200 rows don't fit? Then don't do that. Read the data from your ResultSet and build a Vector of Vectors. Create a DefaultTableModel from that and give it to your JTable as its table model.
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply PAUL,
Can I add the rows Dynamically with an Increment. like i++

and jTable1.addrow(i);

Please assist me for doing this.

Thanks and regards

Aravind Prasad
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!