簡體   English   中英

為什么會出現“ MySQLSyntaxErrorException:”錯誤?

[英]Why do I get a “MySQLSyntaxErrorException:” error?

語法錯誤,我似乎找不到它。 我是數據庫新手。

錯誤:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database ( ID INTEGER NOT NULL, QUESTION varchar(100) NOT NULL, ANSWER varchar(5' at line 1

碼:

public void createTable(Connection conn) {
    try {
        String createString = "CREATE TABLE " + this.tableName + " ( "
                + "ID INTEGER NOT NULL, "
                + "QUESTION varchar(100) NOT NULL, "
                + "ANSWER varchar(500) NOT NULL, " + "PRIMARY KEY (ID))";

        this.sendUpdate(conn, createString); //This part definitely works as intended
        System.out.println("Created a table called " + this.tableName);
    } catch (SQLException e) {
        System.out.println("ERROR: Could not create the table");
        e.printStackTrace();
        return;
    }
}

DATABASEMySQL的保留字 為表格使用其他名稱

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM