开发者

How to find the time taken by an SQL script to execute completely using java code?

I am trying to get the time taken by an SQL scri开发者_如何学Pythonpt to excute completely using java code.I am having jdbc connection code with me.but i do not have logic to get the time taken by an SQL script to execute.can anybody please send me the code to print the time taken by the SQL script to execute? expected result: After executing the java code we should get result as:the time taken by the query is :__


You don't need to use a Calendar instance. Here's a simpler solution:

long millisStart = System.currentTimeMillis();
// run your query here
long millisEnd = System.currentTimeMillis();
System.out.println(millisEnd - millisStart);


Calendar cal = Calendar.getInstance();
long millisStart = cal.getTimeInMillis();
// run your query here
cal = Calendar.getInstance();
long millisEnd = cal.getTimeInMillis();
System.out.println(millisEnd - millisStart);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜