用Java关闭MySQL execute()查询

时间:2016-08-20 10:50:28

标签: java mysql

好的,我有以下代码:

            Statement statement = connection.createStatement();
            boolean resultSet = statement.execute("INSERT INTO guilds(`ID`, `Prefix`, `Join`, `Leave`, `EnableRoles`, `Role`)" 
                +"select col1, col2, col3, col4, col5, col6"
                +"from (select '"+id+"' as col1, '//' as col2, 'Welcome, {user}!' as col3, 'Goodbye, {user}!' as col4, 'false' as col5, 'none' as col6) t"
                +"WHERE NOT EXISTS (SELECT * FROM guilds WHERE ID = '123');");

通常,当你执行executeQuery()时;你有一个resultSet.close();方法

我想知道是否有一个执行()(似乎没有在IDE上弹出),如果没有,是否/如何关闭它像resultSet.close();

感谢。

1 个答案:

答案 0 :(得分:0)

关闭声明statement.close();

最好将所有内容放在try catch块中并在finally子句中执行结束。