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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:43:01+00:00 2026-05-27T04:43:01+00:00

At runtime an application (based on Java/Spring/Hibernate) throws the following exception: 07:18:38.511 ERROR Error

  • 0

At runtime an application (based on Java/Spring/Hibernate) throws the following exception:

07:18:38.511 ERROR Error for batch element #1: The insert or update value of the FOREIGN KEY “SOME_FIELD.SQL_11410213222” is not equal to any value of the parent key of the parent table.. SQLCODE=-530

The stack trace only partially helps in finding the root of the issue (here a foreign key constraint violation).

Is there a way to also print the sql which caused this exception (or at least the parameters used in the statement)? I’m aware this can be achieved by tweaking the logging configuration but then both the statements which run fine and the statements which cause the errors will be logged. I only want to output info relevant to the erroneous statements… Is this doable ?

  • 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-27T04:43:02+00:00Added an answer on May 27, 2026 at 4:43 am

    Log4Jdbc is the JDBC proxy driver that can intercept JDBC calls and log the information such as the exact SQL executed in the DB and the SQL timing information.

    What is nice is that Log4Jdbc can log the actaul values of the binding parameters in the same line .It greatly increase readability IMO compared to the built-in hibenrate logging which the binding paramters are shown as “?” and the actual values of the binding paramters are shown in different lines.

    By setting the logging level of the logger jdbc.sqlonly to ERROR , you can restrict that SQL will only be logged when the exception is thrown.

    Here is the brief points to setup the logging with log4jdbc and log4j. For the detailed configuration , you can refer to the official site

    1.Change to use Log4Jdbc ‘s JDBC driver:

     <property name="connection.driver_class">net.sf.log4jdbc.DriverSpy</property>
    

    2.For the jdbc url that you are using , replace jdbc with jdbc:log4jdbc , for example:

    <property name="connection.url">jdbc:log4jdbc:postgresql://localhost:5432/Test?protocolVersion=2</property>
    

    3.Configure the logging level for different loggers in log4j.properties. For example ,to log the SQL only when the exception is thrown:

    log4j.logger.jdbc.sqlonly=ERROR
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've an application that is based on .NET 2 runtime. I want to add
I have a Java application which is using a certain Java Runtime Environment. The
I have a application where the frontend is based on the Spring Roo 1.1.2
I have a QML based application in Qt that generates some warnings at runtime:
I want to add spring IOC to maven based Swing Application Framework project. So
I am using java annotation based configuration for initializing ehcache based caching, with Spring
I have a processing based Java application that runs fine in Eclipse but the
I have built a multi-touch application which is based on a Java EE backend
My application dynamically loads assemblies at runtime from specific subfolders. These assemblies are compiled
We have a Win32 application that hosts the .NET runtime and opens up .NET

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.