2009-11-29 183 views
0

此方法不斷拋出標題中的異常,我找不到原因,我通過連接創建了其他表,並創建了所有引用的表。我正在使用嵌入式JavaDB爲什麼我會遇到SQLSyntaxErrorException - 遇到「」?

private void createEvidenceTable() throws SQLException 
{ 
    Statement evidenceTable = CONNECTION.createStatement(); 
    evidenceTable.execute("CREATE TABLE evidence("+ 
          "evidence_id INTEGER NOT NULL PRIMARY KEY,"+ 
          "date_added VARCHAR(6) NOT NULL,"+ 
          "evidence_dated VARCHAR(6) NOT NULL,"+ 
          "evidence_file varchar(20),"+ 
          "evidence_text VARCHAR(10),"+ 
          "source_location_id INTEGER,"+ 
          "source_person_id INTEGER,"+ 
          "evidence_type VARCHAR(20),"+ 
"CONSTRAINT evidence__location_source FOREIGN KEY(source_location_id) REFERENCES location_source,"+ 
"CONSTRAINT evidence_person_source FOREIGN KEY(source_person_id) REFERENCES person_source,"+ 
"CONSTARINT evidence_evidence_type FOREIGN KEY(evidence_type) REFERENCES evidence_types)"); 

} 
+0

你試圖在哪個數據庫中創建表? – 2009-11-29 20:01:29

+0

JavaDB,嵌入式,抱歉只做了一個編輯。 – chrisg 2009-11-29 20:02:14

回答

5

一個明確的問題是,第三個約束子句拼寫錯誤(CONSTARINT ISO CONSTRAINT

+0

感謝您的幫助,就是這樣。 – chrisg 2009-11-29 21:04:52

0

這曾在MySQL客戶端:

CREATE TABLE evidence 
(
    evidence_id INTEGER NOT NULL, 
    date_added VARCHAR(6) NOT NULL, 
    evidence_dated VARCHAR(6) NOT NULL, 
    evidence_file varchar(20), 
    evidence_text VARCHAR(10), 
    source_location_id INTEGER, 
    source_person_id INTEGER, 
    evidence_type VARCHAR(20), 
    PRIMARY KEY(evidence_id), 
    FOREIGN KEY(source_location_id) REFERENCES location_source(source_location_id), 
    FOREIGN KEY(source_person_id) REFERENCES person_source(source_person_id), 
    FOREIGN KEY(evidence_type) REFERENCES evidence_types(evidence_type) 
); 

你爲什麼要使用VARCHAR(6)代替日期?對我來說毫無意義。

相關問題