Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

How to get multiple clients to connect to one database

 
Ranch Hand
Posts: 55
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys , so I've been thinking of building a app for my college . It would be used by lecturers for many things ,ie tracking students marks and attendances.

So I'm just in the planing phase and am confused about how I would achieve a shared database for many users(educators ).

What if a user edits a entry that someone else is using at the same time ?

How would I overcome the fact that they would be able to use the system offline and online without causing issues with changes in the online database vs the local version?


Just some confusion and it probably a simple concept I don't understand or missed as a novice ...thanks for the help in advanced for all the help!
 
Saloon Keeper
Posts: 21144
134
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The magic word is "transactions".

Transactions are what you use to ensure the integrity of a shared database when multiple users can be updating at the same time.

Briefly, you start a transaction. Then you do your database operations. Then you commit your transaction. Until you commit the transaction, none of your changes actually take effect in the database.

If you encounter problems while doing the update, you can rollback the transaction. That cancels the transaction and discards the changes that would have been committed.

A variation on transactions is "locking". A lock is where you mark a table, record, or whatever as being held by 1 user and no one else can mess with that database resource until the lock has been released. Locks used to be the way to do things back when mainframes ran databases and databases were more primitive. These days, transactions generally rule.
 
Ray mann
Ranch Hand
Posts: 55
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I'll look into it if I have any issue when I get to coding that modual I'll ask follow up questions here ! Or is there a decent java library for this?
 
Tim Holloway
Saloon Keeper
Posts: 21144
134
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JTA library provides JEE-standard transaction support. Since I use Java Persistence Architecture (JPA) under the Spring Framework, I haven't done any manual transaction service calls in a very long while.
 
grapes are vegan food pellets. Eat this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!