我正在尝试使用IBM mobilefirst平台中的SQL Adapter将数据插入数据库,但是我的代码到达了失败函数...
main.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'sSQLDemo-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]
});
}
答案 0 :(得分:0)
来自messages.log文件:
E FWLSE0099E:调用过程[项目时发生错误 DemoProject] SQLDemo / SqlStatementFWLSE0100E:参数:[project DemoProject] DB2 SQL错误:SQLCODE = -104,SQLSTATE = 42601, SQLERRMC = from; AJAX设置FIRSTNAME =?; ..,DRIVER = 3.61.75。执行 查询:更新AJAX设置FIRSTNAME =?来自AJAX,其中id =? FWLSE0101E: 引起:[项目 DemoProject] com.ibm.db2.jcc.am.SqlSyntaxErrorException:DB2 SQL错误: SQLCODE = -104,SQLSTATE = 42601,SQLERRMC = from; AJAX设置FIRSTNAME =?; .., DRIVER = 3.61.75java.lang.RuntimeException:DB2 SQL错误:SQLCODE = -104, SQLSTATE = 42601,SQLERRMC = from; AJAX设置FIRSTNAME =?; ..,DRIVER = 3.61.75。 ...
无效的数据转换:参数实例vinod无效 请求转换。 ERRORCODE = -4461,SQLSTATE = 42815
下面还有更多例外情况。
在数据库方案中确保您实际上期望字符串,而不是限制值的长度等等。