我已將範圍縮小到這些代碼行,並且我知道它與語法有關。我得到的錯誤是:[微軟] [ODBC Microsoft Access驅動程序]語法中的字段定義部分代碼錯誤,我得到的錯誤從爲:我該如何解決我的java數據庫錯誤?
try {
System.out.println("Creating StockTrades table...");
stmt.executeUpdate("CREATE TABLE StockTrades (userID TEXT(20) CONSTRAINT FK1_StockTrades REFERENCES "
+ "Users (userID), symbol TEXT(8), CONSTRAINT FK2_StockTrades FOREIGN KEY (symbol) "
+ "REFERENCES Stocks (symbol), numStocks INT, pricePerStock DECIMAL(5, 2), "
+ "stocksPurchased INT, stocksSold INT, totalCashPaid DECIMAL(9, 2), "
+ "totalCashReceived DECIMAL(9, 2))");
} catch(Exception ex) {
System.out.println("Exception creating StockTrades table: " + ex.getMessage());
}
try {
System.out.println("Creating StockTrades table primary key index...");
stmt.executeUpdate("CREATE UNIQUE INDEX PK_StockTrades ON StockTrades (userID, symbol) "
+ "WITH PRIMARY DISALLOW NULL");
} catch(Exception ex) {
System.out.println("Exception creating StockTrades index: " + ex.getMessage());
}
不,不是。這與之後的行有關係,因爲如果我排除除userID和符號外鍵以外的所有內容,它就可以正常工作。 – Joshua 2011-02-22 19:48:12