aspose file tools
The moose likes JDBC and the fly likes Obtaining The SQL from a prepared Statement Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Obtaining The SQL from a prepared Statement" Watch "Obtaining The SQL from a prepared Statement" New topic
Author

Obtaining The SQL from a prepared Statement

Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
I have a Prepared Statement

insert into person(firstname,lastname) values(?,?);

and I am setting the firstname and lastname via

Preparedstmt.set(1,"ade");
Preparedstmt.set(2,"yomi");

and the last step is Preparestmt.executeUpdate();

The question i have is i am trying to obtain the SQL executed against the Database,after doing the set and executing the executeUpdate command which method can i use?
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

I do not know any direct way to do this, but you can start for example SQL server profiler and monitor the statement that is going to be executed in the database.

Maybe you could enable logging in the JDBC driver level and see the prepared statement . to enable logging take a look at your driver manual and documenation.


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2343

You can use Ryan Bloom's logdriver.

Regards, Jan


OCUP UML fundamental
ITIL foundation
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Obtaining The SQL from a prepared Statement
 
Similar Threads
Help Me Demistify this
insert statement
Not in aggregate function or group by clause - HSQLDB doesn't like the ORDER BY clause
Insert Query using select statement
Search on name using LIKE statement