Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8976491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:09:11+00:00 2026-06-15T19:09:11+00:00

My application is running on a cluster of 4 nodes. On startup (ServletContextListener) it

  • 0

My application is running on a cluster of 4 nodes. On startup (ServletContextListener) it must execute an SQL script. How to make sure that the SQL is executed only once and not 4 times as each of the nodes will try to execute the same code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:09:12+00:00Added an answer on June 15, 2026 at 7:09 pm

    If you want to execute it exactly once (like scripts that update the database structure) you should use some kind of version field in the database (in the simplest case just a single column/single row table). http://flywaydb.org/ might be a solution for you if you don’t want to do it yourself. If you instead just want to ensure that no to instances are running the same script concurrently, you use basically the same idea but instead of using a version field which is alway increased use same kind of boolean lock which you reset after after your script finishes. If you want to implement ist yourself, be sure to handle concurrent access properly. For example instead of select entry from lock /if entry = 0 update lock set entry = 1 which is non atomic do something like update lock set entry = 1 where entry = 0/check if number affected rows = 1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application running in cluster mode (two nodes) under tomcat/Linux. Unfortunately I've
We have a Java EE-based web application running on a Glassfish app server cluster.
In a commandline Perl Application running on Linux I need to make a phone
We have a 3 machine cache cluster running with SQL configuration provider. The service
Let's say I'm running a cluster with two Weblogic server nodes on two servers
Say you have a 4-node J2EE application server cluster, all running instances of a
I'm planning an application running on Google App Engine. The only worry I would
I have an application running that has entities that might be: CustomerType1, CustomerType2, and
I'm running a database-heavy Java application on a cluster, using Connector/J 5.1.14. Therefore, I
I have a Java EE web application which is running on 2 node cluster

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.