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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:22:14+00:00 2026-06-07T02:22:14+00:00

Connection con; PreparedStatement ps,p2; try { sqlquery = …; ps=con.prepareStatement(sqlquery); ps.executeUpdate(); // using ps2…some

  • 0
       Connection con;
       PreparedStatement ps,p2;


       try
       {
           sqlquery = "...";
           ps=con.prepareStatement(sqlquery);
           ps.executeUpdate();

          // using ps2...some similar process.......
       }
       catch(SQLException sqlex)
       {
              System.out.print(sqlex.getMessage());
       }

I’ve got a doubt that whether is

Is it possible to find out the cause of the specific error made out by a query or update such that i can handle the situation other than just displaying the error message at output console (as here) displaying the cause ?

for eg: if if ps preparedStatement makes a mistake because of duplicate entry or ps because of some foreign key issues etc..then i should be able to analyze the sql error specifically using SQLException object so that i can handle accordingly rather than just displaying error message in the output console

The reason for which i need this is because i want to display the error made by a user working through GUI scenario (in case : here java swing) any error entries he made through an interactive manner by analyzing the SQLException instance….

In short , how to classify errors using a single SQLException instance

Sorry if this question finds ambigous or stupid..!!!

  • 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-07T02:22:16+00:00Added an answer on June 7, 2026 at 2:22 am

    If I understand correctly, you need the methods getSQLState and getErrorCode of class SQLException.

    Look here for further information.

    I hope this helps!

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

Sidebar

Related Questions

I'm using the following setup: public MySQLProcessWriter(Connection con) throws SQLException { String returnNames[] =
String url = getUrl(); try{ Connection con = getConnection(url, username, pwd); }catch(ConnectionException e){ cleanUpUrl(url);
x1.instance3650.db.xeround.com-nino_db [chatserver.sql.MySqlConnection.rehash()] this is con null [.()] connection to MySQL server failed com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Cannot
How do I read connection strings from custom config file (say abc.config) using WebConfigurationManager
If i have the following method - public static void C() { Connection con
Possible Duplicate: when to close Connection, Statement, PreparedStatement and ResultSet in JDBC I've written
android to oracle db: public class OracleActivity extends Activity{ private Connection con; protected void
while (!Server.isShuttingDown) { Server.client = Server.listener.AcceptTcpClient(); Connection con = new Connection(Server.client); } How do
I tried to uplad a pdf file using java.sql.PreparedStatement to mysql Blob field using
if (validateEmailId(email)) { pictureBox5.Visible = true; SqlConnection con = new SqlConnection(conection string); SqlCommand cmd2

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.