Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

refresh table doesn't work

 
Lia Mihaela
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
this is the class conectare_baza


 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic