File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display a PreparedStatement content

 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am using JDBC driver
I would like to know if there is a way to display the SQL query associated
with a
PreparedStatement.
I would like to fill the parameters, and then display the query as it will
be thrown
to the Websphere server to debug my application.
Sample: PreparedStatement ps
= new connection.prepareStatement("Select * from foo where bar = ?") ;
ps.setInt(1, 1) ;
and then use somethind like:
// This line does not actually work. System.out.println("Query is: "
+ps.toString()) ;
// But i would like it to print Query is: Select * from foo where bar = 1
Thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the DebuggableStatement. There is a thread about it here
But first...
"longbeach forever",
Display names are not allowed to be fictitious. Please see the JavaRanch naming policy here then edit your profile to set a valid display name.
Accounts with invalid display names get deleted.
thanks,
Dave.
 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, and i updated my profile
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You just updated it to another invalid display name. You need to look at the JavaRanch naming policy.
Your display name must be two words: your first name, a space, then your last name. Fictitious names are not allowed.
Please try again. It's unfortunate when get deleted through misunderstandings!
thanks,
Dave
 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the DebuggableStatement class seems to be working, i tried it.
But you need to import at least 8 classes ...
isn't there a quicker way ?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic