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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:57:47+00:00 2026-05-26T15:57:47+00:00

Hi all, This is my code, public static boolean updateDB() { Connection cn =

  • 0

Hi all,
This is my code,

public static boolean updateDB() {
  Connection cn = null; 
  PreparedStatement pstmt = null;
  ResultSet rs = null;
  boolean result = false;   
  int number; 
  String insetSQL ="update quan set ten_quan='lin' where id=1"; 
  try {
    cn = LocalDatabasePooling.getInstance().getConnection();
    pstmt = cn.prepareStatement(insetSQL);
    pstmt.executeUpdate();
    result = true;
  } catch (SQLException e) {
    e.printStackTrace();
  } finally {
    if (rs != null) {
      try {
        rs.close();
      } catch (SQLException sqle) { }
    }
    if (pstmt != null) {
      try {
        pstmt.close();
      }
      catch (SQLException sqle) { }
    }
    if (cn1 != null) {
      try {
        cn1.close();
      }
      catch (SQLException sqle) { }
    }
  }
  return false;
}

Is the code above correct? But when I debug, I saw that the line

number = pstmt.executeUpdate();

was not executed and the code below it were not executed too.

when I add watch

pstmt.executeUpdate();

I saw this info

error(during the evaluation

What is wrong?

  • 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-26T15:57:48+00:00Added an answer on May 26, 2026 at 3:57 pm

    Apparently an exception was been thrown which was completely ignored by your code. Something like:

    try {
        // Your code was here.
    } catch (SQLException e) {
        // But you didn't put anything here.
    }
    

    You should at least log/print the stacktrace

    try {
        // Your code was here.
    } catch (SQLException e) {
        e.printStackTrace();
    }
    

    Or, even better, just throw it.

    public SomeObject someMethod() throws SQLException {
        try {
            // Your code was here.
        } finally {
            // Surely close resources here.
        }
    }
    

    Exceptions contain a wealth of information about the cause of the problem and they should not be ignored, unless you really know what you’re doing.

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

Sidebar

Related Questions

I wanted to list all my Recently Used Items. I use this code: public
I found the following code example for Java on RosettaCode : public static boolean
I have this section of code: public static void delete(File f) throws IOException {
Hi all I have this code to check if an item from a textbox
This code below works in all web browsers except IE: <input type="text" name="passwordLogin" value="Password"
I have this code to connect to Active Directory and get all the groups
This Code: Something = new Guid() is returning: 00000000-0000-0000-0000-000000000000 all the time and I
How can I rewrite this code to check for all characters including the swedish
I have this code which gets WP posts, but it gets all the posts
I have this code: $li = $(li, this) Which is selecting all 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.