There are more elegant ways I am sure, but you could also use a 
java.io.BufferedReader and read the file content into a string and execute it 
much as you would a hard coded SQL statement in your class.

Sent from my iPad

> On Mar 21, 2015, at 5:04 AM, Amal Gupta <amal.gup...@aexp.com> wrote:
> 
> Hi Everyone,
>  
> I am trying to execute a hive *.hql file from a java application.  I had 
> tried a couple of ways of doing it through JDBC driver for hive and through 
> spring jdbc template but yet, the only way which was successful for me was to 
> create a runtime process and then execute it.
>  
> The java code to do that is  
>  
> Process p = Runtime.getRuntime().exec((new 
> String[]{"hive","-f","/hive/scripts/demoHiveTable.hql"}));
>  
> Although this works but, I wanted to know if there is better way to do it 
> using some driver functionality or any other api for hive. The method I used 
> will do the execution for me, but yet, in case of failures while executing 
> the hql script, the same will not be visible to the Java application.
>  
> Any pointers or suggestions will be greatly helpful. Thanks in advance.
>  
> Please let me know in case you need any other details from me.
>  
> Regards,
> Amal
> American Express made the following annotations 
> 
> "This message and any attachments are solely for the intended recipient and 
> may contain confidential or privileged information. If you are not the 
> intended recipient, any disclosure, copying, use, or distribution of the 
> information included in this message and any attachments is prohibited. If 
> you have received this communication in error, please notify us by reply 
> e-mail and immediately and permanently delete this message and any 
> attachments. Thank you." 
> 
> American Express a ajouté le commentaire suivant le 
> Ce courrier et toute pièce jointe qu'il contient sont réservés au seul 
> destinataire indiqué et peuvent renfermer des renseignements confidentiels et 
> privilégiés. Si vous n'êtes pas le destinataire prévu, toute divulgation, 
> duplication, utilisation ou distribution du courrier ou de toute pièce jointe 
> est interdite. Si vous avez reçu cette communication par erreur, veuillez 
> nous en aviser par courrier et détruire immédiatement le courrier et les 
> pièces jointes. Merci. 

Reply via email to