当前位置: 首页 > 知识库问答 >
问题:

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

翁烨霖
2023-03-14

由于Java8不支持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;

共有1个答案

韦宣
2023-03-14

查询最初可能不是通过使用Access中的design视图生成的,因为在特定情况下会使用感叹号(而不是简单的点)。无论如何,问题是使用感叹号,而UCANAccess还不支持这一点。替换!和。应该可以解决这个问题(而且它与ms access兼容)。

 类似资料: