Java JDBC Connection Create runSQLExecute(String sql, Map config)

Here you can find the source of runSQLExecute(String sql, Map config)

Description

run SQL Execute

License

Apache License

Declaration

public static boolean runSQLExecute(String sql, Map<String, String> config) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.*;

import java.util.Map;

public class Main {
    public static boolean runSQLExecute(String sql, Map<String, String> config) {
        try {// ww w  .  j a v a2s  . com
            Statement statement = getStatement(config);
            return statement.execute(sql);
        } catch (Exception e) {
            throw new RuntimeException("Failed to execute query:" + sql, e);
        }
    }

    private static Statement getStatement(Map<String, String> config)
            throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
        Class.forName(config.get("driver")).newInstance();
        Connection connection = DriverManager.getConnection(config.get("url"), config.get("user"),
                config.get("password"));
        return connection.createStatement();
    }
}

Related

  1. getTestDBConnection()
  2. getTRECConnection()
  3. getUrlConnection()
  4. getUserConnection()
  5. internalShutdown(String connectionString, int expectedErrorCode, String expectedSQLState)