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

时间:2015-02-05 01:26:48

标签: java jdbc ucanaccess

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

因为我看到一个类似的问题,解决方案与确保正确输入查询有关,这是它试图访问的表的名称:

enter image description here

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 个答案:

答案 0 :(得分:3)

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