Here you can find the source of executeUpdate(Connection conn, String sql)
public static boolean executeUpdate(Connection conn, String sql) throws Exception
//package com.java2s; //License from project: Apache 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 Exception { System.out.println("Update SQL: " + sql); Statement stmt = null;/*from ww w . j a va 2 s . c o m*/ try { stmt = conn.createStatement(); stmt.executeUpdate(sql); } catch (Exception e) { throw e; } finally { close(stmt); } return true; } public static void close(Connection conn) { if (null != conn) { try { conn.close(); conn = null; } catch (SQLException e) { } } } public static void close(Statement stmt) { if (null != stmt) { try { stmt.close(); stmt = null; } catch (SQLException e) { } } } public static void close(ResultSet rs) { if (null != rs) { try { rs.close(); rs = null; } catch (SQLException e) { } } } public static void close(ResultSet rs, Statement stmt) { if (null != rs) { try { rs.close(); rs = null; } catch (SQLException e) { } } if (null != stmt) { try { stmt.close(); stmt = null; } catch (SQLException e) { } } } public static void close(ResultSet rs, Statement stmt, Connection conn) { if (null != rs) { try { rs.close(); rs = null; } catch (SQLException e) { } } if (null != stmt) { try { stmt.close(); stmt = null; } catch (SQLException e) { } } if (null != conn) { try { conn.close(); conn = null; } catch (SQLException e) { } } } }