Database phonegap数据库错误代码5-非错误

Database phonegap数据库错误代码5-非错误,database,sqlite,cordova,Database,Sqlite,Cordova,我正在使用phonegap访问电话数据库。但是我的创建过程每次都调用错误例程,错误代码为5,消息为:非错误 难道不能在一个事务中执行多个sql语句吗 SQLite专家找不到语法错误 createDB: function(error, success) { if(typeof error != 'function') error = this.errorDB; if(typeof success != 'function') success = this.succe

我正在使用phonegap访问电话数据库。但是我的创建过程每次都调用错误例程,错误代码为5,消息为:
非错误

难道不能在一个事务中执行多个sql语句吗

SQLite专家找不到语法错误

createDB: function(error, success) {
        if(typeof error != 'function') error = this.errorDB;
        if(typeof success != 'function') success = this.successDB;
        sql = "DROP TABLE IF EXISTS `boiler`; "
            +"CREATE TABLE IF NOT EXISTS `boiler` ( "
            +" `id` int NOT NULL, `object` int NOT NULL, `number` varchar(100) NOT NULL, "
            +" `volume` double DEFAULT NULL, `brand` varchar(100) DEFAULT NULL, `year` year(4) DEFAULT NULL, "
            +" `price_before` float NOT NULL DEFAULT '0', `price_after` float NOT NULL DEFAULT '0',  `description` TEXT DEFAULT NULL, "
            +" `img1` varchar(200) DEFAULT NULL, `img2` varchar(200) DEFAULT NULL, `img3` varchar(200) DEFAULT NULL, "
            +" `img4` varchar(200) DEFAULT NULL, `img5` varchar(200) DEFAULT NULL,  `img6` varchar(200) DEFAULT NULL, "
            +" `img7` varchar(200) DEFAULT NULL, `img8` varchar(200) DEFAULT NULL, `img9` varchar(200) DEFAULT NULL, "
            +"PRIMARY KEY (`id`)); "

            +"DROP TABLE IF EXISTS `counter`; "
            +"CREATE TABLE IF NOT EXISTS `counter` ( "
            +" `number` varchar(100) NOT NULL, `object` int NOT NULL, `type` tinyint NOT NULL DEFAULT '0', "
            +" `value` double DEFAULT NULL, `access` varchar(100) DEFAULT NULL, "
            +"PRIMARY KEY (`number`)); "

            +"DROP TABLE IF EXISTS `link`; "
            +"CREATE TABLE IF NOT EXISTS `link` ( "
            +" `id` int NOT NULL, `boiler` int NOT NULL, `name` varchar(100) DEFAULT NULL, "
            +" `units` tinyint DEFAULT NULL, `price` float NOT NULL DEFAULT '0', "
            +"PRIMARY KEY (`id`)); "

            +"DROP TABLE IF EXISTS `manager`; "
            +"CREATE TABLE IF NOT EXISTS `manager` ( "
            +" `id` int NOT NULL, `company` varchar(100) DEFAULT NULL, `name` varchar(100) NOT NULL, "
            +" `phone` varchar(15) DEFAULT NULL, "
            +"PRIMARY KEY (`id`)); "

            +"DROP TABLE IF EXISTS `object`; "
            +"CREATE TABLE IF NOT EXISTS `object` ( "
            +" `id` int NOT NULL,  `state` tinyint NOT NULL DEFAULT '0', `user` varchar(50) DEFAULT NULL, "
            +" `date` char(15) DEFAULT NULL,  `street` varchar(100) DEFAULT NULL, `number` varchar(16) DEFAULT NULL, "
            +" `zip` char(5) DEFAULT NULL, `city` varchar(100) DEFAULT NULL, `manager` int NOT NULL DEFAULT '0', "
            +" `units` int NOT NULL DEFAULT '0', "
            +"PRIMARY KEY (`id`));";
        console.log(sql);
        this.DB.transaction(function (tx) { tx.executeSql(sql); }, error, success);
    },

不知道错误代码:5,但您可以执行多个sql语句

         // Wait for PhoneGap to load

            document.addEventListener("deviceready", onDeviceReady, false);

            // PhoneGap is ready

            function onDeviceReady() {
                var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
                db.transaction(populateDB, errorCB, successCB);
            }

            // Populate the database 

            function populateDB(tx) {
                 tx.executeSql('DROP TABLE IF EXISTS DEMO');
                 tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
                 tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
                 tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
        //here you can do  multiple sql statements.
            }

            // Transaction error callback

            function errorCB(err) {
                alert("Error processing SQL: "+err);
            }

            // Transaction success callback

            function successCB() {
                alert("success!");
            }

请从文件资源管理器检查您的数据库

只有在创建表时才会出现问题,就像您输入了四个值一样,但表中只有三列,因此会出现此错误

tx.executeSql(“创建表,如果不存在引号(id INTEGER非空主键自动递增、名称、标志整数、地址、说明、电话号码、日期整数、引号号码、作业、图像)”)

如果直接指定整数值而不是var类型值,则会导致此错误 像flar一样,我使用1或0
但是现在我将这个值存储在var type

中,如果我拆分语句,那么就没有错误,但是我不能全部执行,因为一个transactionexecuteSql只需要一个语句,因此错误代码为5,这意味着解析错误(参考:)。