Here you can find the source of sqlExe(DataSource dataSource, String sql)
public static void sqlExe(DataSource dataSource, String sql)
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; import javax.sql.DataSource; public class Main { public static void sqlExe(DataSource dataSource, String sql) { Connection conn = null;/*from w ww .ja v a2 s .co m*/ Statement stmt = null; try { conn = dataSource.getConnection(); conn.setAutoCommit(false); stmt = conn.createStatement(); stmt.execute(sql); conn.commit(); } catch (Exception e) { if (conn != null) { try { conn.rollback(); } catch (SQLException e1) { // ignore } } e.printStackTrace(); } finally { if (stmt != null) { try { stmt.close(); } catch (SQLException e) { // ignore } } if (conn != null) { try { conn.close(); } catch (SQLException e) { // ignore } } } } }