• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to get multiple clients to connect to one database

 
Ranch Hand
Posts: 55
Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 24287
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 24287
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic