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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:40:26+00:00 2026-06-12T07:40:26+00:00

I have a database that my java program or a web application connects to

  • 0

I have a database that my java program or a web application connects to for persistence of application state. In certain calls to the database, certain exceptions might arise like there
might be a duplicate key exception or some check constraint might fail, or it could be as simple as a bad sql grammer. How can I effectively identify the kind of exception thrown so that an appropriate action based on the type of exception could be taken. For e.g prompting the user that a record already exists in case of duplicate key exception.

There could be a way by checking the exception string but could there be a less tedious way of doing it?

Also, is it possible to obtain more detailed information like if a unique key constraint is violated which of the several unique columns happened to be the culprit?

Please base your answers with respect to Java programming language or any frameworks like Spring based on java.

  • 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-12T07:40:27+00:00Added an answer on June 12, 2026 at 7:40 am

    Use java.sql.SQLException (javadoc here).

    On catching a SQLException you can view its SQLState, it will denote which type of error has ocurred according to the standards (XOPEN or SQL:2003).

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

Sidebar

Related Questions

I have a java program that connects to a MySql database and it's working
I have some Java code that connects to an Oracle database using DriverManager.getConnection(). It
I have a web-app with a Java back-end that uses Tomcat jdbc-pool for database
I have 2 java web apps that need to connect to SQL Server Database
I have a Java Web Start application calling remote Java EE 5 EJBs to
I have a JAX-B java web service which I'm using to update a database.
I have been developing a Java application using J2EE and a Derby database. My
I have some queries being run in a java program that makes use of
I have a database and a Java Program. I am trying to write a
I have a db4o database that was generate by a Java app and I'm

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.