0

i have a project using Springboot and MyBatis to write API like this

@Mapper
public interface ExportJobDetailRepository {
  List<RegularExportDetail> getExportJobDetailById(@Param("id") String id);
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
    namespace="com.toshiba.mwcloud.gs.dbaas.repository.ExportJobDetailRepository">

    <resultMap id="BaseResultMap"
        type="com.toshiba.mwcloud.gs.dbaas.griddbdto.RegularExportDetail">
        <id column="id" property="id" />
        <result column="export_job_id" property="regularExportId" />
        <result column="containers" property="containers" />
        <result column="time_column" property="timeColumn" />
        <result column="row_filter" property="rowFilter" />
        <result column="export_method" property="exportMethod" />
    </resultMap>

    <select id="getExportJobDetailById" resultMap="BaseResultMap">
        SELECT * FROM
        export_job_detail
        where export_job_id = #{id}
        order by containers desc
    </select>
</mapper>

I need to write a function that can set timeout for API, and Kill the query processing if reach timeout. What should i do for this problem ? Thanks a lot

  • Perhaps [this](https://stackoverflow.com/questions/415905/how-to-set-a-maximum-execution-time-for-a-mysql-query) could be used – g00se Apr 25 '23 at 12:36
  • max_excution_query can only use for "select" query, is there any solution for other methods like delete, insert .. ? – Nghi Hoàng Đức Apr 25 '23 at 15:16
  • @NghiHoàngĐức ` – ave Apr 25 '23 at 15:21
  • @ave "timeout" attribute in MyBatis can only throw exception, I need to kill the process if it reaches time out, so which solution can kill the query process in MyBatis ? – Nghi Hoàng Đức Apr 26 '23 at 02:27
  • @NghiHoàngĐức The [doc](https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-implementation-notes.html) says `setQueryTimeout` internally issues `KILL QUERY`. If that is not what you want, please edit the question and elaborate on your requirement. – ave Apr 26 '23 at 12:41

0 Answers0