This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 29220
    
135

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Prepared Statement - printing out the statement
 
Similar Threads
insert 650 fields into oracle table
pre-compile and prepared statement
Create DB2 database
what is better
Urgent Java interview question 6+ yrs exp.