Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sql of prepared statement

 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • 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 ]
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
thanks Reid.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic