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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:45:45+00:00 2026-05-23T06:45:45+00:00

when I connect to database and execute a query, then if there occurs any

  • 0

when I connect to database and execute a query, then if there occurs any exception then I want to fetch only the reason of exception not the full message , so that in my log I can log only the reason of exception for example. one exception is below by applying getMessage() on exception object in catch block
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name ‘tty’.

So I want to fetch only “Invalid object name ‘tty'”.

The exception will occur only due to executeUpdate() method. so exception may be anything related to database or sqlquery not just Invalid object name ‘tty’.

  • 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-23T06:45:45+00:00Added an answer on May 23, 2026 at 6:45 am

    I can’t see anything obvious in SQLException, but I can think of two options:

    • Remove everything in square brackets, possibly with a regex.
    • If you’re always using the same driver, just remove the leading predictable leading substring

    Sample code for the second option:

    private static final String MESSAGE_PREFIX =
        "[Microsoft][ODBC SQL Server Driver][SQL Server]";
    
    ...
    
    String message = exception.getMessage();
    if (message.startsWith(MESSAGE_PREFIX))
    {
        message = message.substring(MESSAGE_PREFIX.length());
    }
    

    That’s likely to be considerably easier than the first option, but is obviously rather more brittle in the face of driver changes. I wouldn’t be surprised to see the message format change for different drivers anyway though…

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

Sidebar

Related Questions

I defined a role and grant it with only connect to database and execute
To test if i can connect to my database, I execute the following code
i want to connect database to iphone sdk but it is taking the default
In code igniter, you can connect database and make queries in controller like: $this->db->query(Your
I have to perform a query similar to: <?php //....connect to database $old =
I can't show the data from database sqlite in python. connection = sqlite3.connect('db') connection.cursor().execute('CREATE
I'm trying to connect my application to my database. I does not give a
I am trying to connect to a MySQL database using Java. I want to
Should I use php PDO or normal mysql_connect to execute database queries in PHP?
Is that possible to connect mysql database between servers. I mean, lets say i

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.