how we can shutdown hsqldb database in java

半城伤御伤魂 提交于 2019-12-21 20:49:12

问题


i am using hsqldb as my database. i want whenerver my select query, update query execute it will shutdown a database. below is the method in which i need a code from which i can manually shutdown my database.

private void insertInitData(BasicDataSource dataSource, int lmexAdapterId, int lmsId) {
    try {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        String lmexPostParam_id = UUID.randomUUID().toString();
        String inertQuery = "Insert into lmex_post_param (lmex_post_param_id, param_name, param_value) values (?,?,?)";
        String[] baseUrlParam = { lmexPostParam_id, "base_url", lmexPostingBaseUrl };
        jdbcTemplate.update(inertQuery, baseUrlParam);
        String lmexPostParamId2 = UUID.randomUUID().toString();
        String[] postServiceParam = { lmexPostParamId2, "post_service_url", lmexPostingPostServiceUrl };
        jdbcTemplate.update(inertQuery, postServiceParam);
        String lmexPostParamId3 = UUID.randomUUID().toString();
        String[] lmsIdParam = { lmexPostParamId3, "lms_id", lmsId+"" };
        jdbcTemplate.update(inertQuery, lmsIdParam);
        String lmexPostParamId4 = UUID.randomUUID().toString();
        String[] adapterIdParam = { lmexPostParamId4, "adapter_id", lmexAdapterId+"" };
        jdbcTemplate.update(inertQuery, adapterIdParam);
        //shutdown database by code
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

the code must be replace in the place of comment "shutdown database by code".

help me

Thank you in advance


回答1:


For example:

jdbcTemplate.execute("SHUTDOWN");



回答2:


use the below code to shutdown your database using java code.

jdbcTemplate.execute("SHUTDOWN");

it works



来源:https://stackoverflow.com/questions/5298035/how-we-can-shutdown-hsqldb-database-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!