Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003

    Unanswered: ugh: Java LOAD DATA [LOCAL] INFILE trouble

    I've been looking all over the net and haven't been able to find clear instructions to: load a file that is sitting on the same machine as the mysql server into a table.

    Below is update and query code that works. However, I can't get the LOAD DATA LOCAL INFILE to work. (The \\\\ are there because of java and mysql special chars. I believe Mark Matthew (MySQL dev?) suggested using 4 backslashes in this way)

    Do I need to install MySQL Connector/J for LOAD DATA to work?

    Can anyone please give me the correct code and/or configuration?


    public void updateDB(){
    try {
    catch (ClassNotFoundException ex) {
    try {
    Connection con = DriverManager.getConnection("jdbcdbc:testDSN", "", "");
    Statement stmt = con.createStatement();

    String filepath = "C:\\\\mysql\\\\bin\\\\";
    String query = "LOAD DATA LOCAL INFILE \'" + filepath + "\' INTO TABLE pet";

    String updateString = "insert into pet values('rex', 'gary', 'dog',NULL,NULL,NULL)";

    ResultSet rs = stmt.executeQuery("SELECT * FROM pet");

    while ( {
    String name = rs.getString("name");
    catch (SQLException ex1) {

  2. #2
    Join Date
    May 2003

  3. #3
    Join Date
    Aug 2003
    FDR India
    I can't get the LOAD DATA LOCAL INFILE to work
    Do you have the privilege to LOAD DATA?

    Do I need to install MySQL Connector/J for LOAD DATA to work?
    NO, if you are working from the mysql client directly.

    YES, to access MySQL through a java application. I don't know any Java programming, but try this - filepath = "c:/mysql/bin/";.

    * Can you LOAD DATA from the mysql client?
    * What errors did you get?

    The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. If the LOCAL keyword is specified, it is interpreted with respect to the client end of the use LOAD DATA INFILE on server files, you must have the FILE privilege...If you have generated the text file on a Windows system you may have to change the above to: LINES TERMINATED BY '\r\n' as Windows uses two characters as a line terminator. Some programs, like wordpad, may use \r as a line terminator
    excerpts from MySQL manual.

    Last edited by then; 08-12-03 at 03:00.

  4. #4
    Join Date
    Nov 2011

    Load data local Infile

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts