I have a SQL script that contains the following
LOAD DATA LOCAL INFILE '.\\datafiles\\customers.txt' INTO TABLE Customers`
I open and run it in MySQL workbench and I get following error:
Error Code: 2. File '.\datafiles\customers.txt' not found
(Errcode: 2 - No such file or directory)
Where should I put file customers.txt according '.\datafiles\customers.txt'?
I use windows 7 and I tried the following placse:
C:\datafiles
C:\temp\datafiles
C:\tem\datafiles
C:\Users\michael\datafiles
I think \\ is incorrect. I Always use full path.
So if the file is in C:\datafiles\ use
LOAD DATA LOCAL INFILE 'C:\datafiles\customers.txt'
INTO TABLE Customers LINES TERMINATED BY '\r\n';
Use absolute path with slash as a separator like this:
'C/your_folder/.../datafiles/customers.txt'
Related
How do I insert a file that resides in windows in c:\temp\sample.txt
I have tried
insert into lob_file VALUES (5, pg_read_file('c://temp//sample.txt')::BYTEA);
and got
ERROR: could not start file c://temp//sample.txt. No such file or
directory.
Is data base running locally or on a Windows server and you have moved the file to the server. See Docs
The functions shown in Table 9.94 provide native access to files on
the machine hosting the server. Only files within the database cluster
directory and the log_directory can be accessed unless the user is
granted the role pg_read_server_files. Use a relative path for files
in the cluster directory, and a path matching the log_directory
configuration setting for log files.
I am using flyway pro with oracleSqlplus enabled. I created a folder structure to organize scripts based on objects. Trying to use # (with path) in the flyway version scripts, which is not working.
folder structure,
topFolder
-folderA
-AScript.sql
-folderB
-BScript.sql
-folderCommon
-AScript.sql
-V1__ASCRIPT.sql
-V2__BSCRIPT.sql
-V3__ASCRIPT.sql
Content of:
V1__ASCRIPT.sql
#AScript.sql -> Which correctly executes topFolder/folderA/Ascript.sql
V2__BScript.sql
#BScript.sql -> Which correctly executes topFolder/folderB/Bscript.sql
V3__ASCRIPT.sql
#topFolder/folderCommon/AScript.sql -> Which is throwing me below error,
org.flywaydb.core.api.FlywayException: SP2-0310: unable to open file "topFolder/folderCommon/AScript.sql"
I tried almost all possible combinations,
with absolute path,
with "#../../topFolder/folderCommon/AScript.sql"
tried setting SQLPATH varible
with ##
which didnt work.
Just giving the file name alone in #, works. But I want to specify the path, so that file names can be re-used and it is less error prone.
I expect the relative path should work with flyway + oraclesqlplus option.
Thanks in advance.
looks like you start the path from the point where fly flyway.locations=filesystem: ends is where your path begins.
Example:
flyway.locations=filesystem:/opt/app/sql
where you scripts are /opt/app/sql/appadb/script.sql
inside masterscript would be
##appadb/script.sql
I am trying to load data in hive through a java program. I am loading the file from my machine.
stmt.executeQuery("load data local inpath 'file:///C:/sample/Documents/sample1.txt' into table " + tablename);
When I execute this program I am getting the following exception
Caused by: java.lang.RuntimeException: java.net.URISyntaxException:Expected scheme-specific part at index 2: C:
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.failExpecting(URI.java:2835)
at java.net.URI$Parser.parse(URI.java:3038)
at java.net.URI.<init>(URI.java:753)
However when I execute the program in a ubuntu machine
stmt.executeQuery("load data local inpath '/home/sample/sample1.txt' into table " + tablename);
The data is loaded correctly to the hive database.
When I execute the program in windows I am getting the exception. How can I solve this?
Path(Uri) syntax in windows is different from ubuntu. In ubuntu we use forward slash where as in windows we use backslash.
Windows: C:\Users\system\Desktop\db
Linux: /home/sample/sample1.txt'
So try changing the syntax of the uri.
I exported a java project as a jar in windows and uploaded the jar to a linux server. On executing the jar I get to see "C:" being appended in the beginning of the file path. Here's the log :
Query : LOAD data infile "/home/user/java_correlation_engine/CorrelationFiles/temp.txt" ignore into table logical_mapping fields terminated by '|' lines terminated by '\n'
java.sql.SQLException: File 'C:\home\user\java_correlation_engine\CorrelationFiles\temp.txt' not found (Errcode: 2 - No such file or directory)
The query looks exactly how I wanted it to be but it throws SQLException.
I have a problem with the full text search database generation in javaHelp. In order to generate the db I have to execute a command from a batch file:
java -cp jhall.jar com.sun.java.help.search.Indexer -db .\JavaHelpSearch .\html
This only works if the batch file is in the same directory of the html directory containing the files to index. I have tried to execute the batch file from an external location using absolute paths:
java -cp jhall.jar com.sun.java.help.search.Indexer -db C:\help\JavaHelpSearch C:\help\html
The db generation give no erros, but if I search a word in the javaHelp window I get the following error:
Failed to create URL from file:/C:/help/myHelp.hs|C:/help/html/myhtml.html
I have spent a lot of time facing this problem, without success. What I really need is to call the Indexer class directly from my Java application, but the same problem happens there.