1

I am using jstl to access a database table. After a query has been executed, I need to find its execution time using jstl. I have attached the code I use:

<sql:update dataSource="${conn}" var="addresses">
    ${query}
</sql:update>

Is there a way to find it? I use ${addresses} to find the number of rows affected.

Thanks in advance

Srikrishnan Suresh
  • 729
  • 2
  • 13
  • 31
  • 1
    What execution time are you looking for? From your app-server or from database? With timezone, without? – Grim Jan 18 '13 at 13:09

1 Answers1

1

A simple solution would be:

<jsp:useBean id="beginUpdate" class="java.util.Date"/>
<sql:update dataSource="${conn}" var="addresses">
    ${query}
</sql:update>
<jsp:useBean id="endUpdate" class="java.util.Date"/>
<c:set var="updateDuration" value="${endUpdate.time - beginUpdate.time}"/>

But this really isn't the best way to accurately time the update. However, if all you need is a general measure of how long it takes, then it's probably fine.

kschneid
  • 5,626
  • 23
  • 31
  • I don't know if its possible but it will be better to get the time values from `System.nanoTime` as explained [here](http://stackoverflow.com/questions/351565/system-currenttimemillis-vs-system-nanotime) – Luiggi Mendoza Jan 18 '13 at 21:41