I'm creating a java class to manage all related to Database Management (Especifically MySQL) and i've been having trouble while trying to update a ResultSet.
The problem is that I have a method that executes an insert query. When I call it creates a new record on the DB but it does'nt appear in the ResultSet. I know i can simply refill the ResultSet again using a Statement Object and call its executeQuery method, but i find it a memory waste to do that only for a single new row.
is there a way to only update the record i just created?
The problem is, I use the resultSet object as global for all the things in the class. I don't know if it is the best way though.
let me explain better, i have a method that show the data in a table, filling up the global ResultSet and then showing its contents in the control. When i update something in the database, i call the method in charge of refreshing, in order to see the changes applied to the control.
the last one, what it does is simply clean up the table and call the method that shows the data. Because the ResultSet keeps the same value it appears like nothing happend to the user, when the changes did apply to the database.
if you have any other idea im opened to it
I am not sure why you are hesitant of executing the query just after the update to populate the global resultset. Why you are too much thoughfull about memory.You should be worried by the memory management.
There is no method by means of which you will update/insert/delete any record and keep track of the data; you need to fire query to get the data.