Reputation: 341
I'm trying to figure out how to connect to Hana XS using http connection from java, I've spent days searching for anything relevant on internet but couldn't find anything.
I was just trying a few thing and the best i could come up with is :
public static boolean testConnection(String host, String port,String userID,String certificate)
{
boolean success = false;
String https_url = "https://"+host+":"+port;
URL url ;
try{
url = new URL (https_url);
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("content-type", "application/x-www-form-urlencoded");
con.setRequestProperty("Authorization", certificate);
int response = con.getResponseCode();
System.out.println("Response: "+ response);
}
catch(Exception e)
{
e.printStackTrace();
}
return success;
}
This Obviously is not working as i don't know how to form the connection string and send the request. Any help will be appreciated.
Upvotes: 0
Views: 1178
Reputation: 31
From the comments it sounded like you are just wanting to see if your XS engine is running, the easiest way to accomplish that is doing something like this:
function doPing(lv_server){
$.ajax({url: "http://"+lv_server+":8090/",
type: "HEAD",
timeout:1000,
statusCode: {
200: function (response) {
$(imgname).attr('src', 'images/online.png');
},
404: function (response) {
$(imgname).attr('src', 'images/offline.png');
},
400: function (response) {
$(imgname).attr('src', 'images/offline.png');
},
0: function (response) {
$(imgname).attr('src', 'images/offline.png');
}
}
});
}
This assumes a standard SAP HANA install where the default port for the XS engine is 80XX where XX is the instance number in this example instance number 90.
Then you are setting an image to indicate offline or online based on the response from the call.
This works for any SAP HANA system running the XS classic (xsc) engine as there is a default "landing page" to indicate the XS engine is up and running.
Upvotes: 0