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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:50:52+00:00 2026-06-04T15:50:52+00:00

I am using Tomcat 6 and Postgresql 8.4. My code looks as follows: try

  • 0

I am using Tomcat 6 and Postgresql 8.4. My code looks as follows:

try {
  // Prepared statement inserting something...
} catch (final PSQLException e) {
  LOG.log(Level.SEVERE, "Saving failed.", e);
} catch (final SQLException e) {
  LOG.log(Level.SEVERE, "Saving failed (SQL).", e);
}

This insert into DB may cause a PSQLException (e.g. a unique key violation) which I want to catch with the first catch. However, what I actually find in the log is this:

SEVERE: Saving failed (SQL).
org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "UZIVATELIA_U_LOGIN"
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
    at cz.ecoremedia.realpad.web.backend.Users.saveNewUser(Users.java:119)
    at cz.ecoremedia.realpad.web.backend.Users.saveUser(Users.java:237)
    at org.apache.jsp.User_jsp._jspService(User_jsp.java:159)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)

If I check the type of e I caught, for example like this:

} catch (final SQLException e) {
  LOG.log(Level.SEVERE, e.getClass().getName());
  LOG.log(Level.SEVERE, "Saving failed (SQL).", e);

It still tells me it was org.postgresql.util.PSQLException.

When I try this locally in my Eclipse, it works perfectly – PSQLException gets caught correctly in the first catch block.

If I understand the problem correctly, the org.postgresql.util.PSQLException I catch is a different class from the org.postgresql.util.PSQLException that actually gets thrown. How is this possible? What am I doing wrong?

Thanks for your ideas.

  • 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-04T15:50:55+00:00Added an answer on June 4, 2026 at 3:50 pm

    Turns out, I had another JDBC driver in my Tomcat’s lib/ folder, apart from the one in WEB-INF/lib/. Removing the Tomcat’s one fixed my problem.

    (Yes, it was a different class loader problem, thanks @NathanHughes.)

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

Sidebar

Related Questions

I'm using tomcat and whenever I log out of my web app and try
I'm using tomcat 6.0 and struts2. When I try to click on a link
I am using Tomcat 6 and have some questions about Apache mod_jk as follows.
Hi I am using tomcat + spring 3.0 ws trying to log request and
We are using Liferay Portal 5.2.3 (with Hibernate and C3P0) on Tomcat 5.5.27, PostgreSQL
I am using tomcat, Java with GWT. When try to connect to db my
I am using tomcat 6 on windows. Here is the code I am testing.
I'm using PostgreSQL 8.2.9, Solr 3.1, Tomcat 5.5 I have following problem: When I
i am using tomcat server and i have added a rhino engine to able
I'm using Tomcat 6.0, and I want to know how can I configure Tomcat's

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.