开发者

What to do if user closes page in the middle of a mysql long query?

W开发者_如何学Gohat happens to the mysql query if the user just closes the page? Should I be doing any kind of checking for this? I'm using JPA 2.0(EclipseLink 2.0), JSF 2.0, EJB 3.1(lite) and Glassfish 3.1. Thanks.


In the database, the query will continue to run until completion. It's possible to kill the session running the query, but there's a security concern with providing that ability outside of the database.


Generally there's nothing you can do to detect it or abort a query in progress. You're stuck with using up the CPU time to finish the process because there's no way to interrupt a query in progress from Java.

Why would this be an issue? What is it that you're trying to avoid?


In JPA you can define a timeout which is passed to JDBC. You can also set a maxResults to limit the number of rows returned.

JDBC now also provides a cancel() API, but JPA does not yet expose this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜