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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:53:23+00:00 2026-05-13T14:53:23+00:00

I have three methods that, together, save a node to the database. Currently, this

  • 0

I have three methods that, together, save a node to the database. Currently, this does not achieve the desired effect of not committing the changes unless all the writes are successful.

    conn.setAutoCommit(false);
    writeNodeTable(node, newNodeNID);
    writeContentTypeBoutTable(node, newNodeNID);
    writeTerms(node, newNodeNID);
    conn.commit();

If there is a problem (such as an uncaught exception is thrown) in the second or third method, I’d like to roll back all the changes. Is there some way I can use transactions to do this?

This is one such DB writing function:

private void writeTerms(DrupalNode node, int newNodeNID) throws SQLException {
    String sql = "INSERT INTO term_node (nid, vid, tid) VALUES (?, ?, ?)";
    PreparedStatement prep = conn.prepareStatement(sql);
    prep.setInt(1, newNodeNID);
    prep.setInt(2, newNodeNID);

    String schoolName = termHelp.schoolOfAgainst(node.get(BoutField.against));
    prep.setString(3, schoolName);

    prep.execute();

    String fencerName = termHelp.fencerOfAgainst(node.get(BoutField.against));
    prep.setString(3, fencerName);
    prep.execute();
    prep.close();
}
  • 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-05-13T14:53:24+00:00Added an answer on May 13, 2026 at 2:53 pm

    You can use rollback method in Connection interface.
    http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Connection.html#rollback()

    Also you have to set setAutoCommit to false and call commit and rollback methods as appropriately.

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

Sidebar

Related Questions

Is there builtin method that would do this or do I always have to
Let us suppose i have these three methods defined: int F1(int, int); int F1(float,
My question is related to exception handling. If i have for example three methods
I have a convenience class for encoding URI's. In it I've created three methods
Lets say I have a test class called ServiceTest with three test methods test1,
PHP mysql database I have created a follow on question to this one here
They brush the subject in this thread, but it does not really answer much:
I have two questions that both work together so I'm putting it in as
Problem: I have a WCF service that invokes methods via reflection and sends the
Assume that this is for a 32-bit application. I have two ID values which

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.