/**
Cancels this <code>Statement</code> object if both the DBMS and
driver support aborting an SQL statement.
This method can be used by one thread to cancel a statement that
is being executed by another thread.
@exception SQLException if a database access error occurs or
this method is called on a closed <code>Statement</code>
@exception SQLFeatureNotSupportedException if the JDBC driver does not support
this method
*/
void cancel() throws SQLException;
贴个Statement.cancel()的文档:
根据javadoc的描述,如果DBMS和驱动都支持的话是可以使用这个api结束
可以先设置超时时间:
捕获这个异常然后cancel()
mysql超时设置吧