• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Storing data that changes

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

This question is probably asked very frequently.

How can I store data (eg email list) that is updated once in a few months.

Currently I have such data in the Constants file, but I can see why its bad practice.

Any articles that I can refer to will be helpful too.

Thanks
 
Sheriff
Posts: 22682
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd go for a database. That way you have good persistent storage.
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.
Suppose I use this data very often in the application. Every email that is sent out etc.

Would it still be better to store it in the database.

Thanks
 
Rob Spoor
Sheriff
Posts: 22682
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can keep it in memory as well:
- read from the database when you start your application
- use the in-memory values throughout
- write to the database when the values change

I prefer to write on change instead of write on exit, because the application may not be shutdown nicely by the operating system when it shuts down. That will cause your changes to be lost. The writing can be done in a background thread as to not cause slowness in the user interface.

Note that with database, I do not necessarily mean a database system like MS SQL Server, Oracle or MySQL. A CSV, XML or properties file can be just as good, depending on the contents you want to store.
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.

Is there any limitation to how much data can be kept in the memory.
Have you experienced any disadvantages with it?

Thanks
 
Rob Spoor
Sheriff
Posts: 22682
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By default, 64MB is the JVM limit. That includes everything so also all Strings etc. Usually that's enough though; I usually got into memory problems with complex or image intensive GUIs only, and if the data set stored is just huge. And then we're talking about millions of records.
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cool.
Thanks!
 
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic