E. Rowlands E. Rowlands - 9 months ago 42
Java Question

Does JDBC have a relative path option when using LOAD DATA LOCAL INFILE?

I'd like to load a text file that is located in a NetBeans project folder.

What is the default relative path (if one exists in

) of the
command? (

I would have assumed it would be the home directory of the compiled code - but it has given me the expected SQL exceptions for not being able to find the file.

I have to hand in an assignment - and so cannot use an absolute path as that would not work on another computer.

Answer Source

From the MySQL documentation for LOAD DATA LOCAL INFILE:

If LOCAL is specified, the file is read by the client program on the client host and sent to the server. The file can be given as a full path name to specify its exact location. If given as a relative path name, the name is interpreted relative to the directory in which the client program was started.

You should try using the location of the client program as being the start of the relative path. The directory of the compiled code does not seem to have anything to do with this.