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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:45:34+00:00 2026-06-08T11:45:34+00:00

I currently face the following problem: I have written a Java program that parses

  • 0

I currently face the following problem:

I have written a Java program that parses XML data and puts the data in a database. Because I use MyBatis, the database could be nearly every database already existing.
I’ll just show you a piece of code and then I will explain the problem.

public void insert(SourceContent content){    
    SqlSession session = sqlSessionFactory.openSession();           
        try {
            session.insert("SourceDocument.insert", content);
            session.commit();
        }   catch (Exception e){
            e.printStackTrace();
        } finally {
            session.close();
        }           
    }

This is my DAO class for calling the sql statements of the MyBatis mapper file. Inserting my content (which is an instance of an java bean) wors fine, if the mapping configuration of MyBatis was done correctly. But imagine, if I rename a table in my database, then the connection fails because the configuration is wrong. Now I want to catch the upcoming error. When i use the statement like above:

catch (Exception e){
            e.printStackTrace();
        } 

the programm prints the right exception: ### Cause: java.sql.SQLSyntaxErrorException: ORA-00942: Tabelle oder View nicht vorhanden
But I dont want to catch all Exception, I just want to catch the SQLSyntaxErrorException, because I want to tell the user, that the his table in the database is not available. But I just cant catch any other exceptions except of the normal Exception like seen above.
I hope I had made it out clearly. Can anyone help me please?

  • 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-08T11:45:36+00:00Added an answer on June 8, 2026 at 11:45 am

    Your exception has been wrapped into another one. Catch that other exception and then analyze its cause. For example:

    try {
       ....
    } catch (PersistenceException e) {
      try { throw e.getCause(); }
      catch (SQLSyntaxException e) {
        // handle the exception
      }
    }
    

    If that is not satisfactory, you can probe the cause with instanceof instead:

    try {
       ....
    } catch (PersistenceException e) {
      final Throwable cause = e.getCause();
      if (cause instanceof SQLSyntaxException) {
        // handle the exception
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We currently have a solution that was completely written by hand in ASP.NET and
I face the following problem in a cryptographical application: I have given a set
I currently face the problem of java.lang.NoClassDefFoundError: com.google.common.collect.HashBiMap when using guava libraries downloaded from
Currently I face the following issue - I create a custom ListView ( 1
I often run in the following problem, I have a web page with the
I am currently trying to find the face in a particular image.I am following
Dear, I currently face some problem to retrieve the value of a property setted
So situation is following : We have some very old product, that has dozen
At work we currently have a PostgreSQL database and we access it via some
What I am currently trying to do is use the Face API to detect

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.