Java examples for JDBC:SQL Statement
execute Update sql
//package com.java2s; 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 { Statement stmt = null;/* w w w .ja v a2 s.com*/ 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, Statement stmt) { if (null != rs) { try { rs.close(); rs = null; } catch (SQLException e) { } } if (null != stmt) { try { stmt.close(); stmt = null; } catch (SQLException e) { } } } }