com.hadoopz.cloud.JCloud.SDK.utils.SqlExecutor Maven / Gradle / Ivy
The newest version!
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.hadoopz.cloud.JCloud.SDK.utils;
import com.mycomm.IProtocol.log.UniversalLogHolder;
import com.mycomm.YesHttp.core.HttpMethod;
import com.mycomm.YesHttp.core.Request;
import com.mycomm.YesHttp.core.Response;
import com.mycomm.YesHttp.core.StringRequest;
import com.mycomm.YesHttp.core.TextBaseResponseListener;
import com.mycomm.YesHttp.core.YesHttpEngine;
import com.mycomm.YesHttp.core.YesHttpError;
import com.mycomm.itool.SystemUtil;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
/**
*
* @author jw362j
*/
public class SqlExecutor {
public String execute(final String sql, final String jcloudToken) {
String url = EndpointBuilder.getFullUrlForExecuteSql();
//final JSONObject ps = new JSONObject();
Request request = new StringRequest(HttpMethod.POST, url, new TextBaseResponseListener() {
@Override
public void responseMe(String msg) {
try {
YesLog.yeslog.d("the requestjSON TextBaseResponseListener.responseMe:" + msg);
JSONObject datas = new JSONObject(msg);
} catch (JSONException ex) {
UniversalLogHolder.d(getClass().getSimpleName(), ex.getMessage());
}
}
}, new Response.ErrorListener() {
public void onErrorResponse(YesHttpError error) {
YesLog.yeslog.e("the requestjSON ErrorListener.onErrorResponse:" + error.getMessage());
}
}, YesLog.yeslog, Request.Protocol.HTTP) {
@Override
public void getHeaders(Map headers) {
headers.put("Authorization", jcloudToken);
}
@Override
public void getParams(Map ps) {
ps.put("theSql", SystemUtil.base64Encode(sql));
ps.put("jcloudToken", jcloudToken);
}
};
YesHttpEngine.getYesHttpEngine().send(request);
return null;
}
}