// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package test;

import java.sql.*;

public class MysqlLock {
    public static void main(String[] args) {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection("jdbc:mysql://localhost/Test", "", "");
            Statement stmt = con.createStatement();
            stmt.execute("LOCK TABLES T1 WRITE");
            stmt.executeUpdate("INSERT INTO T1 VALUES (123, 'ABC')");
            stmt.execute("UNLOCK TABLES");
            stmt.close();
            con.close();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
