Load data Query hive using file path in windows

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.

Need Your Help

Circular reference found while reading from Unix without copying to Local using Spring Integration

spring spring-data spring-integration spring-cloud pivotal-cloud-foundry

I want to read .txt files from Unix location without copying it to local using Spring Integration.And this should be done in a continuous mode i.e as an when a new file comes it should be detected ...

Solr - How to get a document that has the minimum price

solr max minimum

I have a Solr instance which contains documents that represent products. Each document has a UnitPrice attribute associated with it, which is of type float, in the schema.xml.