Java SQL Execute execute(String sql, Connection connection)

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

Description

execute

License

Apache License

Declaration

public static void execute(String sql, Connection connection) 

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 {
    public static void execute(String sql, Connection connection) {
        Statement shutdown = null;
        try {/*  w w  w .  j a va2s .c om*/
            shutdown = connection.createStatement();
            shutdown.execute(sql);
        } catch (SQLException sqle) {
            throw new RuntimeException(String.format("Failed to execute SQL [%s]", sql), sqle);
        } finally {
            if (shutdown != null) {
                try {
                    shutdown.close();
                } catch (SQLException e) {
                }
            }
        }
    }
}

Related

  1. execute(Connection connection, String sql)
  2. execute(Connection connection, String sql, boolean closeConn)
  3. execute(final String url, final String username, final String password, final String sql, final Consumer consumer)
  4. execute(List sql)
  5. execute(Statement statement, String sql)
  6. executeCall(Connection connection, String command, String schemaName, String tableName, int paramLength)
  7. executeCallable(Connection conn, String sql)
  8. executeCreateDB(String className, String URL, String userName, String password, String dbName)
  9. executeDDL(final Connection connection, final String sql, final int... ignoreErrors)