用户缺少权限或未找到保存查询的对象错误

User lacks privilege or Object not found error for saved query

由于 Java 8 不支持 JDBC 我正在尝试修改我的程序,以便它仍然可以从 Microsoft Access 数据库中提取和修改数据。

它一直抛出 SQL异常。目前这是我的代码打开数据库连接并进入查询的样子:

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");

并且因为我看到了一个类似的问题,解决方案必须确保查询输入正确,这是 table 它试图访问的名称:

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;

查询最初可能不是使用 Access 中的设计视图生成的,因为在特定情况下会使用感叹号(而不是简单的点)。无论如何,问题在于使用了 ucanaccess 尚不支持的感叹号。 更换!和 。应该可以解决问题(并且它与 ms 访问兼容)。