Here you can find the source of executeUpdate(Connection conn, String sql)
public static boolean executeUpdate(Connection conn, String sql) throws SQLException
//package com.java2s; /*/*from w w w. jav a2s . co m*/ * Copyright Red Hat, Inc. and/or its affiliates * and other contributors as indicated by the @author tags and * the COPYRIGHT.txt file distributed with this work. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { public static boolean executeUpdate(Connection conn, String sql) throws SQLException { Statement stmt = null; try { stmt = conn.createStatement(); stmt.executeUpdate(sql); } finally { close(stmt); } return true; } public static void close(Connection conn) throws SQLException { close(null, null, conn); } public static void close(Statement stmt) throws SQLException { close(null, stmt, null); } public static void close(ResultSet rs) throws SQLException { close(rs, null, null); } public static void close(Statement stmt, Connection conn) throws SQLException { close(null, stmt, conn); } public static void close(ResultSet rs, Statement stmt) throws SQLException { close(rs, stmt, null); } public static void close(ResultSet rs, Statement stmt, Connection conn) throws SQLException { if (null != rs) { rs.close(); rs = null; } if (null != stmt) { stmt.close(); stmt = null; } if (null != conn) { conn.close(); conn = null; } } }