Worklight版本6.2
部署适配器,服务器已启动。
我正在使用以下代码来调用SQL过程:
DataAccessService service = WorklightBundles.getInstance().getDataAccessService();
ProcedureQName procedureQname = new ProcedureQName("EAttendanceSQLAdapter", "checkDomain");
String paramArray = "['"+userName+"']";
System.out.println("paramArray : "+ paramArray);
logger.info(">>>>>>>>>>>after procedureQname>>>>>>>>>>>>>>>>>>>>>");
InvocationResult result = service.invokeProcedure(procedureQname,paramArray);
com.ibm.json.java.JSONObject resultJsonObject = result.toJSON();
它扔我
显示java.lang.NullPointerException 在这一行“DataAccessService service = WorklightBundles.getInstance()。getDataAccessService();”
请咨询。但是同一组代码在不同的项目中对我有用。
由于
答案 0 :(得分:0)
有些东西不对IMO有以下几行......
String paramArray = "['"+userName+"']";
这是一个有效的例子:
import com.ibm.json.java.JSONObject;
import com.worklight.server.bundle.api.WorklightBundles;
import com.worklight.server.integration.api.DataAccessService;
import com.worklight.server.integration.api.InvocationResult;
import com.worklight.server.integration.api.ProcedureQName;
public void callProcedure() {
DataAccessService service = WorklightBundles.getInstance().getDataAccessService();
String paramArray = "['param1', 'param2', 'param3']";
ProcedureQName procedureQName = new ProcedureQName("adapterName",
"procedureName");
InvocationResult result = service.invokeProcedure(procedureQName,paramArray);
JSONObject jsonObject = result.toJSON();
String value = (String)jsonObject.get("key");
}