• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

sql of prepared statement

 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I get a String representation of the sql that my prepared statement is holding(with the question marks replaced with actual parameters) ?

The reason I am asking this is because I am getting a DB2Exception as follows


COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0407N Assignment of a NULL value to a NOT NULL column "" is not allowed. SQLSTATE=23502



When I checked the values in logical layer, all are not null. I hope if I see the sql I can figure out which value is null.
[ January 18, 2006: Message edited by: jiju ka ]
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't. That string-with-question-marks is actually what is used for communicating with the database. The values, referred to as bind parameters, are shipped separately.
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Reid.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jiju,
If you search this forum for DebuggableStatement, you will find a tool that shows you the values of the bound parameters. However, it is more likely that there are fields in the table that are not being referenced from the insert. These would default to null, which may not be allowed.
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my bean to persistence mapping I misspelled a field. This was the cause for not setting the not nullable field.

I had to spend around 20 minutes debugging.

Thanks for the help.
 
reply
    Bookmark Topic Watch Topic
  • New Topic