• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

refresh table doesn't work  RSS feed

 
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
 
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
Boost this thread!