import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class Main {
public static void main(String[] argv) throws Exception {
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 comma-separated
stmt.executeUpdate("LOAD DATA INFILE \"" + filename + "\" INTO TABLE "
+ tablename + " FIELDS TERMINATED BY ','");
}
}
|