Results 1 to 3 of 3

Thread: LOAD DATA INFILE problem....

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    27

    LOAD DATA INFILE problem....

    Hi guys,

    I have got a question regarding LOAD DATA INFILE.

    1. I want to import a txt file into mysql database.
    when I use the following query in the mysql> prompt its fine.
    which is

    when I do it java I am getting error

    Error
    -----------
    java.sql.sqlException: General error message from server:
    "File 'D:/Sen.txt' not found <ErrCode: 2>"


    But the file exists
    Code:
    Code:
    try {
               con = DriverManager.getConnection(url, "root", "");
                stmt = con.createStatement();
                stmt.executeUpdate(createString);
                String filename = "D:/Sen.txt";
                String tablename = "IMPORT";
    stmt.executeUpdate("LOAD DATA INFILE \"" + filename + "\" INTO TABLE " + tablename + " FIELDS TERMINATED BY ','");
                stmt.close();
                con.close();
    }
    My text file(Sen.txt) is like this...

    abc,1
    bcd,2
    adf,3

    I dont know why its say like that
    Can anyone help me out in this...

    thanks...
    senthil.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: LOAD DATA INFILE problem....

    Is the URL to localhost? LOAD DATA INFILE reads from the computer where MySQL is running.
    Does the DB have access rights to the file?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    27

    Re: LOAD DATA INFILE problem....

    Hai CornedBee..

    thanks for ur reply..

    i already found the solution..

    i just put a LOCAL keyword in the query like this

    LOAD DATA LOCAL INFILE \"" + filename + "\" INTO TABLE " + tablename + " ...

    Now itzz perfectly working...

    thanks for ur reply..
    senthil

Posting Permissions

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



Click Here to Expand Forum to Full Width