• Post Reply Bookmark Topic Watch Topic
  • New Topic

Obtaining The SQL from a prepared Statement

 
Abiodun Adisa
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jan Cumps
Bartender
Posts: 2620
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Ryan Bloom's logdriver.

Regards, Jan
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!