Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class Main {
    public static void main(String[] argv) throws Exception {
        Connection connection = DriverManager.getConnection(url, username, password);
        Statement stmt = connection.createStatement();

        // Load the data
        String filename = "c:/infile.txt";
        String tablename = "mysql_2_table";
        stmt.executeUpdate("LOAD DATA INFILE \"" + filename + "\" INTO TABLE " + tablename);

        // file is terminated by \r\n, use this statement
        stmt.executeUpdate(
                "LOAD DATA INFILE \"" + filename + "\" INTO TABLE " + tablename + " LINES TERMINATED BY '\\r\\n'");

    }
}