Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving query from preparestatement

Status
Not open for further replies.

frebluestar

Programmer
Jan 10, 2005
2
US
Hi

I am working with Queries which has large number of Columns. I am using Preparestatement to set the values and execute the queries.

Is there any way by which I can get the final query which is build after all the data values are set in preparedstatement .

It is very time consuming to check for the faulty data value through Java , when u have large number of columns.

That's why I want a final query with values set in that so that I can execute this query in SQL Plus or similar tools , which will pin point the data value error.

Can any one suggest me the best way to accomplish this.

thanks in advance.......
 
The problem is that a PreparedStatement is designed so that the SQL statement is compiled and stored by the database server, and then the java program simply sends the database server arguments that get plugged in to the already-complied SQL.

In other words, the java application doesn't really HAVE the completed SQL statement, so there isn't any way to retrieve it. The statment gets cobbled together by the database server.

You might consider using java's Proxy support to build a proxy that would intercept the arguments as you're adding them and at least log them somewhere. The Proxy class is in java.lang.reflect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top