我正在尝试使用 IBM mobilefirst 平台中的 SQL 适配器将数据插入数据库,但是我的代码达到了失败功能......
主.js:
function insertData(){
alert("Function InsertData called");
var fname = document.forms["form1"]["fname"].value.toString();
var lname = document.forms["form1"]["lname"].value.toString();
var email = document.forms["form1"]["email"].value.toString();
var pwd = document.forms["form1"]["pwd"].value.toString();
// alert("fname"+fname);
var invocationData = {
adapter: 'SQLDemo',
procedure: 'procedure4',
parameters:[fname,lname,email,pwd]
};
var options = {
onSuccess : InsertDataSuccess,
onFailure : InsertDataFailed,
timeout : 30000
};
WL.Client.invokeProcedure(invocationData, options);
}
function InsertDataSuccess(result){
alert("Success");
WL.Logger.debug("Retrieve success" + JSON.stringify(result));
}
function InsertDataFailed(result){
alert("Failure");
WL.Logger.debug("Retrieve success" + JSON.stringify(result));
}
Adapter的SQLDemo-impl.js:
var procedure4Statement = WL.Server.createSQLStatement("INSERT INTO INNOVATION (FIRSTNAME,LASTNAME,EMAIL,PASSWORD) VALUES(?,?,?,?)");
function procedure4(fname,lname,email,password) {
return WL.Server.invokeSQLStatement({
preparedStatement : procedure4Statement,
parameters : [fname,lname,email,password]
});
}