Ibm mobilefirst 使用mobile first studio在sql中已创建的表中插入数据
请需要你的帮助。我已经复制粘贴和修改了下面的项目从伊丹阿达尔后关于插入数据。我已经有一个表与2行数据,我需要添加一个额外的到它。虽然一切看起来很好,我不能插入数据到表中。控制台帮助中也没有显示任何错误,请大家注意,提前感谢 index.htmlIbm mobilefirst 使用mobile first studio在sql中已创建的表中插入数据,ibm-mobilefirst,mobilefirst-adapters,Ibm Mobilefirst,Mobilefirst Adapters,请需要你的帮助。我已经复制粘贴和修改了下面的项目从伊丹阿达尔后关于插入数据。我已经有一个表与2行数据,我需要添加一个额外的到它。虽然一切看起来很好,我不能插入数据到表中。控制台帮助中也没有显示任何错误,请大家注意,提前感谢 index.html <html> <head> <meta charset="UTF-8"> <title>demo2</title>
<html>
<head>
<meta charset="UTF-8">
<title>demo2</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<!--
<link rel="shortcut icon" href="images/favicon.png">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
-->
<link rel="stylesheet" href="css/main.css">
<script>window.$ = window.jQuery = WLJQ;</script>
</head>
<body style="display: none;">
<!--application UI goes here-->
<h1>Please Enter The Student Details</h1>
<form >
student id:<input type="number" id="stdid" ><br><br>
student name<input type="text" id= "stdname" > <br><br>
<input type="submit" value="Register" onclick="insertValuesToDB();">
</form>
<script src="js/initOptions.js"></script>
<script src="js/main.js"></script>
<script src="js/messages.js"></script>
</body>
</html>
adapter.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed Materials - Property of IBM
5725-I43 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
<wl:adapter name="Insertadap"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.ibm.com/mfp/integration"
xmlns:sql="http://www.ibm.com/mfp/integration/sql">
<displayName>Insertadap</displayName>
<description>Insertadap</description>
<connectivity>
<connectionPolicy xsi:type="sql:SQLConnectionPolicy">
<!-- Example for using a JNDI data source, replace with actual data source name -->
<!-- <dataSourceJNDIName>java:/data-source-jndi-name</dataSourceJNDIName> -->
<!-- Example for using MySQL connector, do not forget to put the MySQL connector library in the project's lib folder -->
<dataSourceDefinition>
<driverClass>com.mysql.jdbc.Driver</driverClass>
<url>jdbc:mysql://localhost:****/hello</url>
<user>****</user>
<password>***</password>
</dataSourceDefinition>
</connectionPolicy>
</connectivity>
<!-- Replace this with appropriate procedures -->
<procedure name="insertvaluesprocedure"/>
<procedure name="procedure2"/>
</wl:adapter>
在Chrome和Chrome DevTools中预览应用程序时,应用程序处于打开状态,并且您使用该应用程序-您在Chrome DevTools控制台中看到的错误是什么 此外,错误可能只是在适配器XML中声明了一个过程“procedure2”,但在客户端代码中调用的是“procedure1” 将“程序1”更改为“程序2”
编辑:根据注释,它似乎是类型不匹配 假设stdid应该与数据库中的int字段相对应,这显然是一个问题,因为在JavaScript中,默认情况下它被视为字符串 所以你有两个选择:
var stdid=stdid*1代码>,然后将其更改为number,然后数据库可能会接受它
我的适配器本身在第1行的列“studid”中显示问题{“errors”:[“Runtime:不正确的整数值:''。\n执行的查询:\n插入studentdb(studid,studname)值(?,)“,“info”:[],“isSuccessful”:false,警告:[]}听起来您的数据库中的类型与您提供的数据库中的类型不匹配。在JavaScript中,它总是字符串,但也可能是int,所以可以将数据库更改为string.my db just 2 field int和varchar field。我需要做的是什么,int是什么,varchar是什么?哪个是stdid,哪个是stdnam?我不理解你的想法,你知道。在mysql中,我有两个字段integer stdid和varchar stdname,只想通过ibm mobilefirst将数据输入这些字段
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed Materials - Property of IBM
5725-I43 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
<wl:adapter name="Insertadap"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.ibm.com/mfp/integration"
xmlns:sql="http://www.ibm.com/mfp/integration/sql">
<displayName>Insertadap</displayName>
<description>Insertadap</description>
<connectivity>
<connectionPolicy xsi:type="sql:SQLConnectionPolicy">
<!-- Example for using a JNDI data source, replace with actual data source name -->
<!-- <dataSourceJNDIName>java:/data-source-jndi-name</dataSourceJNDIName> -->
<!-- Example for using MySQL connector, do not forget to put the MySQL connector library in the project's lib folder -->
<dataSourceDefinition>
<driverClass>com.mysql.jdbc.Driver</driverClass>
<url>jdbc:mysql://localhost:****/hello</url>
<user>****</user>
<password>***</password>
</dataSourceDefinition>
</connectionPolicy>
</connectivity>
<!-- Replace this with appropriate procedures -->
<procedure name="insertvaluesprocedure"/>
<procedure name="procedure2"/>
</wl:adapter>
var users = WL.Server.createSQLStatement("INSERT INTO studentdb(stdid,stdname) VALUES(?,?)");
function insertvaluesprocedure(stdid,stdname) {
return WL.Server.invokeSQLStatement({
preparedStatement : users,
parameters : [stdid,stdname]
});
}