怎么了?
mysql> create table price(
-> p_code char(1) not null,
-> p_description varchar(20),
-> p_rentfee decimal(2,2) not null,
-> p_dylatefee decimal(2,2));
Query OK, 0 rows affected (0.18 sec)
mysql> create table movie(
-> mv_no char(4) not null,
-> mv_name varchar(50) not null,
-> mv_year char(4) not null,
-> mv_cost decimal(2,2) not null,
-> mv_genre varchar(15) not null,
-> p_code char(1) not null,
-> foreign key (p_code) references price(p_code));
ERROR 1215 (HY000): Cannot add foreign key constraint
mysql>
Run Code Online (Sandbox Code Playgroud) 构造函数似乎没有将值放入表达式变量中.如果是这样,它不会正确地将它传递给tokenizer.当我调试它似乎只是传递构造函数内的行.我理解我编写的代码的方式是在main()中调用构造函数,字符串应该存储在解析器内的表达式变量中,然后表达式应该传递给Tokenizer(),但表达式变量在传递时为null.我需要将字符串存储在表达式变量中,然后再传递给Tokenizer().
public class Parser {
String expression;
Tokenizer tokenizer = new Tokenizer(expression);
Parser(String e) {
this.expression = e;
}
}
public static void main(String[] args) {
// TODO code application logic here
Parser parser = new Parser("3+5");
}
Run Code Online (Sandbox Code Playgroud)