Mysql的。无法创建表错误号150

时间:2014-11-10 21:07:19

标签: java mysql jdbc

我正在尝试运行的代码:

            String createESK =      "CREATE TABLE `encrypted_symmetric_keys` ("+
                                    "`id` int(11) NOT NULL AUTO_INCREMENT,"+
                                    "`key_path` varchar(100) NOT NULL,"+
                                    "`file_id` int(11) NOT NULL,"+
                                    "`user_id` int(11) NOT NULL,"+
                                    "PRIMARY KEY (`id`),"+
                                    "KEY `fk_file_id_id` (`file_id`),"+
                                    "KEY `fk_user_id_id` (`user_id`),"+
                                    "CONSTRAINT `fk_user_id_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),"+
                                    "CONSTRAINT `fk_file_id_id` FOREIGN KEY (`file_id`) REFERENCES `files` (`id`)"+
                                    ") ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=latin1;";
            System.out.println("555");
            stmt = conn.createStatement();                      
            stmt.executeUpdate(createESK);

这是我得到的错误:

java.sql.SQLException: Can't create table 'SafeBoxMkVIII.encrypted_symmetric_keys' (errno: 150)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3597)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3529)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1990)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2151)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2619)
        at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1698)
        at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1617)
        at DBTest.<init>(DBTest.java:74)
        at DBTest.main(DBTest.java:446)

此时我迷路了,不知道为什么创造不起作用。

0 个答案:

没有答案