• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get the source of created statement

 
tausahmed ahmed
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have resultset developed using statement like,
Resultset rset = stmt.executeQuery("select ....");
Later at some stage I want to know the query using which resultset is developed i.e. I want to know the string which have used as parameter to the executequery() method.
Please give me solution.
 
Paulo Salgado
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know any method in the API that would give you that, but I've done this with PreparedStatemens by inspecting the object after a breakpoint in a debugger. A field with the SQL statement may be implementation-dependent, but you may want to try it. In my case I was using DB2 and it was there.
Paulo.
 
Lu Battist
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd suggest you either keep track of the sql string yourself, or create a wrapper that would store the sql string for you in an object letting you retreive it on demand. There is nothing ready made in the API to do this.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!