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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:42:10+00:00 2026-05-25T02:42:10+00:00

This program is about auto complete. When I type something to the textfield ,

  • 0

This program is about auto complete. When I type something to the textfield, a list of suggestions will appear.

I make the method onWordUpdated() for a list of suggestions from the DB when I type something to the textfield.

Now, the problem is I have this error:

exception java.sql.SQLException is never thrown in body of corresponding try statement

I made a comment in the code so that you will know which line.

Could someone help me how to fix this?

thanks..

I have this code:

public void onWordUpdated(final String toComplete)
  {
    new Thread(new Runnable()
    {
      public void run()
      {
        try
        {
          final List<Suggestion> suggestions = suggestor.getSuggestions(toComplete);
          SwingUtilities.invokeLater(new Runnable()
          {
            public void run()
            {
              try
              {
                suggestionWidgetModel.clear();
                for (Suggestion suggestion : suggestions)
                  suggestionWidgetModel.addElement(suggestion.getCaption());
                if (!suggestions.isEmpty())
                  suggestionWidget.setSelectedIndex(0);
              }
              catch (SQLException e) // This line is my problem, Could someone help me how to fix this? Thanks.. 
              {
                e.printStackTrace();
              }
            }
          });
        }
        catch (SQLException e1)
        {
          onSqlError(e1);
        }
      }
    }, "onWordUpdated").start();
  }
  • 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-25T02:42:11+00:00Added an answer on May 25, 2026 at 2:42 am

    The compiler is simply telling you that you don’t need to catch that exception at that point.

    SQLException is a checked exception, which means that your code should only see it if you either explicitly throw it, or you call a method that declares it in its throws clause. Neither of these is true for the code in that particular try/catch block.

    You should be able to just get rid of the inner try/catch block and probably the outer one too.


    IIRC, it is theoretically possible to see checked exceptions that haven’t been declared, but this unlikely to arise unless you take special steps to make it happen.

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

Sidebar

Related Questions

working with a big list This is my earlier post about this program which
This program I'm doing is about a social network, which means there are users
I'd like to know what you think about this part of our program is
This is about plugin features in my program. I need a C++ class(and object)
I got a question about this program, it says: The FizzBuzz Challenge: Display numbers
I want to hear your opinion about program life monitoring. This is the scenario.
Please suggest me a more efficient alternative to go about this Program #include <stdio.h>
I want to have a Singleton that will be auto instantiated on program start.
Consider this use case scenario: I wish to auto complete and provide the skeleton
I recently asked about functional programs having no side effects, and learned what this

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.