由于 Java 8 不支持 JDBC,我正在尝试修改我的程序,以便它仍然可以从 Microsoft Access 数据库中提取和修改数据。
它不断抛出 SQLException。目前,这是我的代码在打开与数据库的连接并进入查询时的样子:
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
con = DriverManager.getConnection("jdbc:ucanaccess://C:/Users/Andrew/Dropbox/Public/Schoolwork/IRC/BBFBL/BBFBLMasterVersion3.accdb"); //name of ODBC driver
Statement stmt = con.createStatement();
stmt.executeQuery("SELECT * FROM DraftNightQuery");
而且因为我看到了一个类似的问题,其中解决方案必须确保正确键入查询,这是它试图访问的表的名称:
DraftNightQuery SQL:
SELECT Players.ID, Players.Last, Players.First, TotalStats.team, Players.DraftStatus, TotalStats.pos, Players.OwnerID, Owners.TeamName, Salaries! [Salary] AS Salary, [TotalStats]![games_DH] AS DH, [TotalStats]![games_C] AS C, [TotalStats]![games_1B] AS 1B, [TotalStats]![games_2B] AS 2B, [TotalStats]![games_3B] AS 3B, [TotalStats]![games_SS] AS SS, [TotalStats]![games_LF]+[TotalStats]![games_CF]+[TotalStats]![games_RF] AS [OF], TotalStats.PG, TotalStats.GS, Players.PositionType
FROM Salaries INNER JOIN (Owners RIGHT JOIN (Players LEFT JOIN TotalStats ON Players.ID = TotalStats.ID) ON Owners.OwnerID = Players.OwnerID) ON Salaries.ID = Players.ID
WHERE (((Players.OwnerID) Is Null))
ORDER BY Players.Last, Players.First;