Here you can find the source of executeSqlAutoCommit(Connection connection, String sql)
Parameter | Description |
---|---|
connection | the connection to initialize |
sql | the SQL to execute |
Parameter | Description |
---|---|
SQLException | throws if the init SQL execution fails |
public static void executeSqlAutoCommit(Connection connection, String sql) throws SQLException
//package com.java2s; //License from project: Apache License import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; public class Main { /**/*from w w w . ja v a 2 s . c o m*/ * Execute the user-specified init SQL. * * @param connection the connection to initialize * @param sql the SQL to execute * @throws SQLException throws if the init SQL execution fails */ public static void executeSqlAutoCommit(Connection connection, String sql) throws SQLException { if (sql != null) { connection.setAutoCommit(true); Statement statement = connection.createStatement(); try { statement.execute(sql); } finally { statement.close(); } } } }