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

  • Home
  • SEARCH
  • 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 7861169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:35:26+00:00 2026-06-02T22:35:26+00:00

I’m using HSQLDB. Inside a java function I’m creating a temporary table and populating

  • 0

I’m using HSQLDB. Inside a java function I’m creating a temporary table and populating it with some data. Right after I’m updating a regular table with the data from the temporary table.

If I debug the code inside the function and perform SELECT I can see that the data was indeed updated in both tables, but after committing the changes the table is no longer updated! (the regular table, not the temporary one).

When I created the temp table I used: ON COMMIT PRESERVE ROWS but it doesn’t help.

Does anyone know why is this happening?

Thanks!

Here is the code:

public synchronized void foo(String[] objectsToMark) throws Exception {

        String createTempTableQuery = "CREATE TEMP TABLE "+TEMP_TABLE_NAME+"(OBJECTID VARCHAR) " +
                "ON COMMIT PRESERVE ROWS";
        String dropTempTableQuery = "DROP TABLE "+TEMP_TABLE_NAME;

        String updateQueryString = "update " + TABlE_A + " set " +TABlE_A+".X = 'N' where "+TABlE_A+".RESULT_ID in (select "+TABlE_A+".RESULT_ID FROM "+TABlE_A
                        +" inner join "+TABLE_B+" on "+TABLE_B+".OBJECTID = "+TABlE_A+".OBJECTID"
                        +" inner join TEMP_TABLE on "+TABLE_B+".OBJECTID = TEMP_TABLE.OBJECTID"
                        +" where "+TABlE_A+".IS_X = 'Y')";

        String insertObjectIDs = "INSERT INTO " + TEMP_TABLE_NAME + " (OBJECTID) VALUES (?)";
        Connection conn = null;
        Statement stmt = null;
        PreparedStatement psInsertObjectIDs = null;
        try {
            conn = getConnection(getClass().getName() + "");
            stmt = conn.createStatement();


            stmt.execute(createTempTableQuery);

            // insert object's IDs into table
            psInsertObjectIDs = conn.prepareStatement(insertObjectIDs);

            for (String id : objectsToMark) {
                int i = 0;
                psInsertObjectIDs.setString(++i, id);
                psInsertObjectIDs.addBatch();
            }
            psInsertObjectIDs.executeBatch();

            stmt.execute(updateQueryString);

        } catch (Exception e) {
        } finally {
            // close resources
            close(stmt);
            stmt = null;
            // drop the temporary tables
            if (conn != null) {
                try {
                    stmt = conn.createStatement();
                    stmt.execute(dropTempTableQuery);
                } catch (SQLException e) {
                }
                close(stmt);
            }

            close(psInsertObjectIDs);
            closeConnection(conn);
        }
    }

Notice that there is no commit here but the connection is configured to perform auto commit.

  • 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-02T22:35:30+00:00Added an answer on June 2, 2026 at 10:35 pm

    As the code works when you debug, the problem must be outside this code.

    If you are running this code as an isolated test on a file: database, and you have not specified a write delay or shutdown option in the jdbc connection url, then the engine does not get enough time to write the data to disk.

    The default settings of HSQLDB are for production, where a SHUTDOWN is issued by the application program. For tests, use either of the properties below.

    This one writes the changes after each commit or auto-commit, therefore slows down production databases:

    jdbc:hsqldb:file:mydb;hsqldb.write_delay=false
    

    This one shuts down the database when the only remaining connection is closed:

    jdbc:hsqldb:file:mydb;shutdown=true
    

    As this issue comes up quite often, future versions of HSQLDB from 2.2.9 will always write the data to disk when the only remaining connection is closed.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to construct a data frame in an Rcpp function, but when I
I have thousands of HTML files to process using Groovy/Java and I need to
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the

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.