Java SQL Execute executeStatement(Connection con, String sql)

Here you can find the source of executeStatement(Connection con, String sql)

Description

Insert data into the database.

License

Open Source License

Parameter

Parameter Description
con the connection instance
sql the sql to be executed

Exception

Parameter Description
SQLException if any sql error

Declaration

static void executeStatement(Connection con, String sql) throws SQLException 

Method Source Code


//package com.java2s;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Main {
    /**//from  ww  w .j a v a2s .  com
     * Insert data into the database.
     *
     * @param con the connection instance
     * @param sql the sql to be executed
     *
     * @throws SQLException if any sql error
     */
    static void executeStatement(Connection con, String sql) throws SQLException {
        PreparedStatement ps = con.prepareStatement(sql);
        ps.executeUpdate();
    }
}

Related

  1. executeSQLCommand(Connection conn, String sql, byte[] blob)
  2. executeSQLCommandWithResult(Connection conn, String sql)
  3. executeSqlFile(Connection connection, String sqlPath)
  4. executeSqlFile(String filename, Connection connection)
  5. executeSqlFromSql(Connection connection, String sql, String name)
  6. executeStatement(Connection conn, String command)
  7. executeStatement(final String databaseName, final String statement)
  8. executeStatements(final Connection conn, final List statements)
  9. executeUnRegister(String schemaName, String tableName, String columnName, Connection con)