aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes refresh table doesn't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "refresh table doesn Watch "refresh table doesn New topic
Author

refresh table doesn't work

Lia Mihaela
Greenhorn

Joined: Jun 15, 2010
Posts: 6
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

Joined: Nov 18, 2006
Posts: 174
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?


Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
Lia Mihaela
Greenhorn

Joined: Jun 15, 2010
Posts: 6
this is the class conectare_baza


Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
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

Joined: Jun 15, 2010
Posts: 6
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

Joined: Nov 18, 2006
Posts: 174
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: refresh table doesn't work