It's not a secret anymore!*
The moose likes JDBC and the fly likes Prepared Statement - printing out the statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Prepared Statement - printing out the statement" Watch "Prepared Statement - printing out the statement" New topic
Author

Prepared Statement - printing out the statement

Baba Bizlowsky
Ranch Hand

Joined: Dec 15, 2003
Posts: 39
How do you "print out" on the screen the contents of the Prepared Statement?

Thanks in advance. Cheers!
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Baba Bizlowsky wrote:
I can't understand what is wrong in here...

I have a simple table: PERSON [ID (integer), NAME (string), SURNAME (string)]



result of that is:




What comma? I KNOW this is something trivial and I'm probably missing it due to it being 3am, but it is driving me nuts.. help, please?

You should be using PreparedStatement#executeUpdate() for INSERT/UPDATE/DELETE queries.


How do you "print out" on the screen the contents of the Prepared Statement?

Thanks in advance. Cheers!

Wrap PreparedStatement with an own implementation which decorates the original PreparedStatement and let the setter methods write to some buffer. There are libraries out for this such as p6spy.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30116
    
150

I recall reading that JAMON does that.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Baba Bizlowsky
Ranch Hand

Joined: Dec 15, 2003
Posts: 39
Thanks.

Especially on the answer of the original question which I edited out because I didn't think anyone would bother analyzing actual code.

I''l check out this Jamon.

Cheers!
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
I don´t see how printing the statement would help the original problem.

Just post the actual problem. If printing the statement might solve the problem, we´d mentioned it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Prepared Statement - printing out the statement
 
Similar Threads
Create DB2 database
pre-compile and prepared statement
what is better
insert 650 fields into oracle table
Urgent Java interview question 6+ yrs exp.