• 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

refresh table doesn't work

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a table wich extends DefaultTableModel
I made a button "Salveaza produs" for add new data,




and a button "Refresh" for refresh table,



but my refresh button doesn't work. my new row doesn't appear in the table

The buttons are in diferent classes. Where did i wrong, how can i refresh my table
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can only assume that a class called 'conectare_baza' has something to do with JDBC, I don't know for sure, because I don't speak that language. English would seem a perfect choice for naming classes and variables, so that the code becomes more readable for all us out there...

In your ActionListener implementation for the refresh button you execute a query. You close the ResultSet before reading any data. I don't think that is what you intended to do?
 
Lia Mihaela
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is the class conectare_baza


 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you read / comprehend my second paragraph? I'm sure you'd wanted to read some fields from the ResultSet before closing it.
 
Lia Mihaela
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i read / comprehend your second paragraph. I agree with you, but tell me where can i close it.
I tried to close it after second "try" and still not working please help me
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a small example for using a prepared statement:


And here's the example with a 'normal' statement (because, you were using PreparedStatement but I think you meant not to):


You may also look into the JdbcFaq -> http://faq.javaranch.com/java/JdbcUsageQuestions
 
Stop it! You're embarassing me! And you are embarrassing this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic