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 9093839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:12:15+00:00 2026-06-16T23:12:15+00:00

I have a web application which is based on SQL Server 2012, and I

  • 0

I have a web application which is based on SQL Server 2012, and I use Java to update data in the database. (Windows Server 2008, JSP, Tomcat7, Java7)

The relevant code is as follows:

public static synchronized int execute(String dsName, String packageAndFunction, List fields) {

        // prepare insertStr
        String executeStr = buildStatement(dsName, packageAndFunction, null, fields);
        dbConn  = DBConnection.getInstance();
        Connection conn = dbConn.getConnection();
        CallableStatement stmt = null;
        int result = RESULT_FAILED;
        try {
            stmt = conn.prepareCall(executeStr);

            // fill statement parameters (each ?)
            fillStatement(stmt, fields);

            stmt.execute();
            result = stmt.getInt(fields.size());

        } catch(SQLException e) {
            Log.getInstance().write("Exception on executeGeneral (" + packageAndFunction + ") " + e.toString());
        } finally {
            try {
                stmt.close();
                dbConn.returnConnection(conn);
            } catch(SQLException e) {
                Log.getInstance().write("Exception on executeGeneral (" + packageAndFunction + ") " + e.toString());
            }
        }
        return result;      
    }

About 90% of the time, the code works great. The rest of the time there is some kind of lock on the table which will disappear by itself in perhaps half an hour or so. The lock prevents even simple SELECT queries on the table from executing (in SQL Server Management Studio). In severe cases it has prevented the entire application from working.

I had an idea to use stmt.executeUpdate() instead of stmt.execute(), but I have tried to research this and I do not see any evidence that using stmt.execute() for updating causes locks.

Can anyone help?
Thanks!

  • 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-16T23:12:17+00:00Added an answer on June 16, 2026 at 11:12 pm

    It’s difficult to diagnose with that code. The next time that it happens, pull up your activity monitor on the SQL server and see what sql command is holding the lock.

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

Sidebar

Related Questions

We have a web based (ASP.NET MVC) application that uses SQL Server 2008 for
Hi I have a page in my java/jsp based web application which shows list
I have a Java Web-Start-based application, which utilizes several native ".exe" utilities. All jars
My organization currently delivers a web application primarily based on a SQL Server 2005/2008
We have a high volume web application based on ASP.NET 3.5 and SQL 2008
I have a web-based application which is very highly reliant on jquery / javascript,
I have a web application which process the data collected from different client machines
I have a web application which uses the globalization values being passed from sql
Here's my problem: I have an application which uses sql server express 2005, and
We have a web application in which the users perform ad-hoc queries based on

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.