Goal : To use RJDBC with OpenCPU AJAX Post call.
Use case : I need to connect with Apache phoenix database and get some data. And on that data I am supposed to do analytics. So to connect with Phoenix i am using rjdbc(phoenix doesn't support any other option to connect).
Environment : public.opencpu.org
Here is what I am trying:
html
<textarea>
library(RJDBC)
.. do some data fetching and then r statistics
</textarea>
<br />
<button id="submitbutton" >Execute</button>
<br />
<br />
<div id="output">
</div>
javascript
<script type="text/javascript">
//When Document is Ready
$(function () {
var baseurl = "https://public.opencpu.org";
//because identity is in base
ocpu.seturl(baseurl+"/ocpu/library/base/R");
//actual handler
$("#submitbutton").on("click", function(){
//arguments
var mysnippet = new ocpu.Snippet($("#input").val());
//perform the request
var req = ocpu.call("identity", {
"x" : mysnippet
}, function(session){
session.getStdout(function(outtxt){
$("#output-txt").text(outtxt);
});
});
//if R returns an error, alert the error message
req.fail(function(){
alert("Server error: " + req.responseText);
$("#output").hide();
});
req.always(function(){
$("button").removeAttr("disabled");
});
});
});
</script>
scenario
when i click execute button, gets the user entered value from text area ( here library(RJDBC) and some db operations) and sends a ajax post and responds back with the below error
google chrome console log :
POST https://public.opencpu.org/ocpu/library/base/R/identity 400 (Bad Request)
OpenCPU error HTTP 400
package 'rJava' could not be loaded
Hope this gives better clarity.
Need to confirm whether rJava works with OpenCPU, if so any possible work around to fix this?