简体   繁体   中英

Execution time of a sql query using jstl

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM