我正在创建一个java应用程序,我已连接到mysql数据库。我尝试使用外键创建一个表,下面的错误execute("CREATE TABLE " + BBBBB + "("
+ " id int(11) NOT NULL AUTO_INCREMENT,\n"
+ " consultantID varchar(225) NOT NULL,\n"
+ " name varchar(225) NOT NULL,\n"
+ " gender varchar(225) NOT NULL,\n"
+ " age varchar(225) NOT NULL,\n"
+ " email varchar(225) NOT NULL,\n"
+ " mobile varchar(225) NOT NULL,\n"
+ " address varchar(225) NOT NULL,\n"
+ " PRIMARY KEY (id)"
+ ") ENGINE=InnoDB DEFAULT CHARSET=latin1"
);
execute("CREATE TABLE " + AAAAA + "("
+ " id int(11) NOT NULL AUTO_INCREMENT,\n"
+ " patientID varchar(225) NOT NULL,\n"
+ " name varchar(225) NOT NULL,\n"
+ " gender varchar(225) NOT NULL,\n"
+ " age varchar(225) NOT NULL,\n"
+ " insurance varchar(225),\n"
+ " mobile varchar(225) NOT NULL,\n"
+ " address varchar(225) NOT NULL,\n"
+ " PRIMARY KEY (id)"
+ ") ENGINE=InnoDB DEFAULT CHARSET=latin1"
);
execute("CREATE TABLE " + CCCCC + "("
+ " id int(11) NOT NULL AUTO_INCREMENT,\n"
+ " patientID varchar(225) NOT NULL,\n"
+ " consultantID varchar(225) NOT NULL,\n"
+ " time varchar(225) NOT NULL,\n"
+ " date varchar(225) NOT NULL,\n"
+ " renewCount INTEGER default 0,\n"
+ " FOREIGN KEY (patientID) REFERENCES AAAAA(pID),\n"
+ " FOREIGN KEY (consultantID) REFERENCES BBBBB(cID),\n"
+ " PRIMARY KEY (id)"
+ ") ENGINE=InnoDB DEFAULT CHARSET=latin1"
是我的表
#!/bin/sh
saxonb-xslt -ext:on -xsl:varnovar.xsl -it:'template-novar' && {
cat novar.xml
}
printf "\n"
saxonb-xslt -ext:on -xsl:varnovar.xsl -it:'template-var' && {
cat var.xml
}
printf "\n"
exit
我收到了如上所述的错误。将根据要求添加其他代码。感谢
答案 0 :(得分:4)
pID
和cID
似乎不存在,它们应该是patientID
和consultantID
创建使用变量AAAAA
和BBBBB
的表,但在第三个语句中,您将它们称为字符串常量“AAAAA”和“BBBBB”,其中可能不正确,您应该始终使用变量,例如:
" ... REFERENCES " + BBBBB + "(cID) ... "