Realising changes in an open ResultSet

Hello,
I'm currently working on a project using simple JDBC and Swing and having some problems getting the application to realise changes made to a resultset that is open all the time.
I have a simple Manager class that, in essence, looks like this:
class CustomerManager {
private ResultSet results;
private int count;
public void load() {
   Statement st = con.createStatement();
   results = st.executeQuery( "select * from customers" );
   results.last();
   count = results.getRow();
public void getCount() {
   return count;
public Customer getCustomer( int index ) {
   results.absolute( index+1);
   //Load via JDBC DAO
   return new JDBCCustomer( results );
}There are several thousand customers in my database so I guess this is the preferred way of doing it (Correct?)
To update a customer, the code looks somewhat like this:
public void updateCustomer( int id, Customer cust ) {
   String sql = "update customers set name = .... where id=" + id );
   Statement st = con.createStatement(  sql );
   st.executeUpdate()
}The problem is that because the update takes place outside the already open ResultSet it doesn't seem to realise the changes to a specific customer. The only solution I've found is to reload the entire ResultSet by calling CustomerManager.load() once again, this is not desirable because there are several different ways of loading the resultset and I don't want to keep track of which way I did it. Is there an easier way of doing things? a reload() method perhaps or maybe a constant telling the resultset to be aware of changes?
I am using MySQL 5.0 with the MySQL 3.1.13 JDBC Driver.
Thanks in advance!
//John

>
Really? Care to elaborate? I thought it was the only
way of doing things when you had really big
resultsets. What would you do/recommend?In terms of memory/process several thousand isn't very large. I have a transaction based server that is designed to cache 2 million entities. I certainly don't use an open result set for that.
In terms of a GUI having any sort of display with several thousand rows is wrong. Users know what they are looking for so make them give you that information and then return the couple or even one record that they are actually looking for.

Similar Messages

  • Problems changing the max open files attribute (ulimit)

    I realised that I posted this message in the wrong section
    (newbie corner) but there is no way to delete a message
    so this was a duplicate of the one in Kernel & Hardware
    Issues
    Last edited by Rehto (2009-04-06 08:53:52)

    Rehto wrote:
    I'm trying to change the max open files by
    putting this line to /etc/security/limits.conf
    <username> hard nofile 4096
    but nothing changes ('ulimit -n' spits as 1024 as an answer).
    I did try to logout and log back in and reboot the
    system but no go
    set the soft limits first. smth like:
    <your_name> soft nofile 4096
    <your_name> hard nofile 4096
    ulimit always uses the soft resource limit first. hard limits kills the application then, if it goes mad.
    vlad
    ps: logout then login again...
    Last edited by DonVla (2009-04-06 11:25:56)

  • I have a mac air and an iMac and both have Pages. I use Pages on my air and save all documents to iCloud. I can see them on my iMac but it won't open with Pages. It becomes visible if I change it to open with preview but I can't interact with it.

    I have an mac air and an iMac 5k - pages runs on both.  I use pages on my air and save all my documents to iCloud drive. I can see the documents on my iMac but some won't open in pages which is bizarre? They will open if I change it to open with preview but then all I can do is read it  - I can't add to the document - All I want is to be able to see all my documents on all my devices and to be able to have them sync so I can add to the documents from  any of my devices. I also have an iPhone 6 and an iPadair2 but I would be happy just to have the iMac and macair sync for starters. I have folders within folders in my documents,. The folders which contain pdf's and individual files open OK . The one I am having difficulty with is the file which I use for ongoing correspondence - in other words it is quite long - I keep adding to it  ( by copying letters in and letters out so I can see a sequential history of what has been going on by scrolling down ) in date order so that it could be 1 - 100 pages long - but I don't think the size is a problem. I don't understand why some folders can open and others not . Has anyone any suggestions please. I have been trying to get this to work for months since iCloud drive came in. It has got much better but it is still not good enough  - or maybe it's me?

    All I can suggest is that you open that file on the MBA and save it as a new file, then see if you can open the new one on the iMac.

  • How do you change the last opened date in Lion?

    In many screens the files are organized automatically by last opened date.  This information is not available when you click command info on the individual file, however, if you list out the files and click on the option to show last opened on the row on the top you will see this information.
    From time to time it is useful to change the creation and modification dates to move where files are displayed in various windows.  While there are utilities and articles about changing the creation and last modified date using third party software or the terminal, I have not been able to find any way to change the last opened date.  This is useful if you wish to hide a file you recently opened so that another user can't just find it as one of the last opened files. 
    When I googled this question all the solutions using terminal either with touch -t or touch -mt commands changed the creation and modification dates, but did not affect the last opened date.
    Anyone have a solution to this?

    Thank you MacNix!!!!!

  • How do I get my themes to stay put. they change everytime I open FF.

    My themes keep changing everytime I open FF. How do I get them to stay put. Your help is appreciated.
    Thank you

    Troubleshooting extensions and themes
    * https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes
    Check and tell if its working.

  • Can I read changes in an open Excel spreadsheet?

    Can I make changes to an open Excel spreadsheet and have a Vi read the spreadsheet containing the changes?

    There are several examples for working with excel in the example finder (Help>>Find Examples). Here is a recent discussipon about this.
    Try to take over the world!

  • How do you change what programs open on starting up?

    How do you change what programs open on start up?

    By changing the list of login items for your user account in System Preferences, and if Lion is automatically reopening applications, which ones are running when the computer is shut down.
    (64981)

  • IMovie modified date changes if only opened

    Whenever I open an iMovie file only to view it, not make any changes, then close the file, the Finder changes the modified date and time to equal the "Last Opened" date and time. I have noticed this through several generations of iMovie so I assume that everyone experiences the same.
    What I wish to know is if this will have an impact on the backup process. For example, I have a pair of external hard drives containing iMovie projects. One is the source and the second is the backup. Many of the files are quite large, some as large as 25 GB. I surely wouldn't want my backup software to attempt to backup a 25 GB file simply because I opened it.
    Does anyone know why the Modified time and date should change simply by opening a file and if my backup concerns are real.

    My iMovie program, too, changes the modified date to the last opened date even if I don't modify it. I suspect that that's the way the program is designed.
    I don't know the answer to your backup concerns. Would depend on what preferences that you set for your backup software. Easiest way to find out would be to make a small iMovie project, save it, then reopen and resave, and see what your backup program does with it.
    You may get more definitive responses from others on this forum.

  • Changing the default opener in Bridge

    My Bridge has decided to change the default opener from Photoshop CS4 to either Quicktime , Paint or Dreamweaver.
    So now I cannot preview a picture in Bridge and then open it in Photoshop
    Can anyone tell me how to change the default back to Photoshop.

    I feel like we are not having the same discussion as I am repeating myself.  Either I am misinterpreting your problem, or you are misinterpreting the suggestions.
    Have you opened Windows Explorer and click one Tools? Should be a tab that says File Type.  Look what the default "opens with" setting is for jpeg files.  You want it to be CS4.  Bridge is not a separate program, but subprogram of photoshop.
    Also, did you go to Bridge and click on edit/preferences/file type associations?  Is CS4 shown there a program for jpeg?

  • FF 19 for Mac. changed preferences to open PDFs with Acrobat Reader. Now when I click on a pdf link, an about:blank FF window opens (pdf then opens)

    The change in preferences opens the pdf appropriately with Acrobat Reader, as desired, but before it does, FF opens a brand new blank window (about:blank). How can that action be stopped?

    Yes, I mean the eternal application.
    Ctrl-click does open the dialog, but that does not cause new/blank FF window to show up.....however shift-click opens the new/blank window, then opens another FF window with a "New Tab" heading, then opens the pdf with Acrobat Reader.....
    If open the dialog and select "open in new tab" (open in Acrobat Reader is not an option), a new tab is opened, and the the pdf come up in Reader (without opening a new FF window). In earlier FF, it just opened directly in Reader (or acrobat) without opening a new tab or window.
    Thanks

  • Changing the default open folder

    Does anyone know how I can change the default open folder in Illustrator? It keeps going to the Documents folder when I try to open a file and I'd like to change it to another folder.

    Cohek wrote:
    Does anyone know how I can change the default open folder in Illustrator? It keeps going to the Documents folder when I try to open a file and I'd like to change it to another folder.
    Illy defaults to / recognises the *last* opened folder unless that's been shifted or some kind of housekeeping (such as clear all history) has been undertaken. In which case, and on first opening, it will open the default folder which will be 'My Documents' .

  • My Mac air book screen automatic change and automatic open different programs during my working it's move its self and I lost my work and mouse pointer automatic dance. Help me to solve

    My Mac air book screen automatic change and automatic open different programs during my working it's move its self and I lost my work and mouse pointer automatic dance. Help me to solve
    Any one can help me

    Thank you for your response - I'll give it a go.
    Also, just to update, my iMac cursor seems to glitch a little bit less now. It seems that at least ONE of my problems may have been caused by sitting my iPhone upon my WACOM tablet. The tablet must receive some sort of disruption from having my phone on it - and removing it seems to remedy a fraction of my mouse-jumping problems - if only for a meanwhile.
    The mouse cursor still does jump around on its own occasionally, and the other mouse problems do persist - so this must not be the only culprit for my array of problems.

  • I have factory open  iPhone 4 now I want to change to factory open iPhone  5 how can I do that

    I have factory open iPhone 4 now I like to change to factory open iPhone 5 . How one do that

    Posting twice will not helped, see your other post for answer.

  • Setting always change when i open ms word on my pc..

    why every time I make a setting with ms word for mac always change when I open it with ms word program on your pc?

    Why would you expect a setting in one program on one operating system to affect the setting in another program on another operating system? I likely did not understand your issue from your description. Or do you mean for example if you create a document using red for the type color that the color changes to another color when you open the document in another installation of Word?
    I suggest you ask in the Office for Mac forums. http://answers.microsoft.com/en-us/mac?auth=1

  • [SOLVED] Problems changing the max open files attribute (ulimit)

    I'm trying to change the max open files by
    putting this line to /etc/security/limits.conf
    <username> hard nofile 4096
    but nothing changes ('ulimit -n' spits as 1024 as an answer).
    I did try to logout and log back in and reboot the
    system but no go
    P.S. I also tried adding 'ulimit -n 4096' to ~/.bashrc
    but then I get:
    bash: ulimit: open files: cannot modify limit: Operation not permitted
    so should I add it to the global profile file
    (etc/profile right?) or to /root/.bashrc or what?
    Last edited by Rehto (2009-04-06 12:08:32)

    Rehto wrote:
    I'm trying to change the max open files by
    putting this line to /etc/security/limits.conf
    <username> hard nofile 4096
    but nothing changes ('ulimit -n' spits as 1024 as an answer).
    I did try to logout and log back in and reboot the
    system but no go
    set the soft limits first. smth like:
    <your_name> soft nofile 4096
    <your_name> hard nofile 4096
    ulimit always uses the soft resource limit first. hard limits kills the application then, if it goes mad.
    vlad
    ps: logout then login again...
    Last edited by DonVla (2009-04-06 11:25:56)

Maybe you are looking for

  • Using phone as Ipod Touch

    I have an original iphone I was using like an ipod touch for wifi and apps etc... not connected to at&t. After I updated to 3.0 it is prompting me to activate phone with at&t. I don't want to sign up for phone service with AT & T i just want to use m

  • Isolation_level value

    hi gurus, how to find the current isolation_level of a session? many thanks

  • Storing Outgoing Documents for scriptform as PDF

    We use archive parameter to transpot scriptform to PDF. We display Chineses characters in the script form. But when I opened form, the Chinese Characters do not display correctly. I try to preview the form in foreground, it display correctly. So I am

  • Unable To Access SAP Support Portal

    Hi Guys, When i tried to connect SAP Support Portal i am getting the fallowing Error. An authorization error occurred when you tried to access the requested document. This may be because you are not authorized to access this document. But on other Ma

  • Unable to uninstall cs6 beta version due to Adobe Application Manager error

    A few weeks ago I installed the beta version of cs6 but never was able to run that program due to the Adobe Application Manager error I received each time I attempted to launch it.  I never found any solutions on the internet so I just gave up.  Rece