Java SQL Execute executeSqlAutoCommit(Connection connection, String sql)

Here you can find the source of executeSqlAutoCommit(Connection connection, String sql)

Description

Execute the user-specified init SQL.

License

Apache License

Parameter

Parameter Description
connection the connection to initialize
sql the SQL to execute

Exception

Parameter Description
SQLException throws if the init SQL execution fails

Declaration

public static void executeSqlAutoCommit(Connection connection, String sql) throws SQLException 

Method Source Code

//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();
            }
        }
    }
}

Related

  1. executeSql(Connection conn, String sql)
  2. executeSQL(Connection conn, String sql)
  3. executeSql(Connection conn, String sql)
  4. executeSQL(Connection connection, String file)
  5. executeSQL(Connection session, String sql, Object... params)
  6. executeSQLCommand(Connection conn, String sql, byte[] blob)
  7. executeSQLCommandWithResult(Connection conn, String sql)
  8. executeSqlFile(Connection connection, String sqlPath)
  9. executeSqlFile(String filename, Connection connection)