wood burning stoves 2.0*
The moose likes JDBC and the fly likes update a ResultSet from the DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "update a ResultSet from the DB" Watch "update a ResultSet from the DB" New topic
Author

update a ResultSet from the DB

raul Alejandro Montero Cruz
Greenhorn

Joined: Jun 05, 2008
Posts: 10
Hi,

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?

here is the code that adds the row:


Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Raul,
I think the answer is no. In the Oracle docs they show how you can insert a row into a result set but not to get a new row from the database.

How long lived is your ResultSet that this is a problem?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
raul Alejandro Montero Cruz
Greenhorn

Joined: Jun 05, 2008
Posts: 10
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
And thanks

heres the code to show the data:
Sisir Chanda
Greenhorn

Joined: Jan 03, 2005
Posts: 11
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: update a ResultSet from the DB
 
Similar Threads
total number of rows in ResultSet
problem in updating a row in JDBC
resultset.next() implicitly closed in MySQL
ResultSet closed error (URGENT !!)
what is difference between JDBC1 and JDBC2 ?