简体   繁体   English

Java运行MS Access查询

[英]Java run Ms Access query

I need to run queries of Ms Access file and the problem is that there is not any sql code to execute from my java code. 我需要运行对Access文件的查询,问题是没有任何sql代码可以从我的java代码中执行。 When I try to see sql code of query 当我尝试查看查询的sql代码时

The SQL statement could not be executed because it contains ambiguous outer joins 无法执行该SQL语句,因为它包含模糊的外部联接

alter is shown. 显示了alter。 So i must call and run queries. 因此,我必须调用并运行查询。 I tried to open and run spesific queries by cmd .bat file. 我试图通过cmd .bat文件打开并运行特殊查询。 However I cannot find any script for solution. 但是,我找不到解决方案的任何脚本。 Is there any sql code to run any query from another query? 是否有任何SQL代码可以运行来自另一个查询的任何查询? if it is possible it can help me. 如果可能的话可以帮助我。 How I can solve this problem? 我该如何解决这个问题?

You could call/run a macro in an Access-database from a bat-file and the called macro could run the query via the macro-command OpenQuery . 您可以从bat文件中调用/运行Access数据库中的宏,被调用的宏可以通过宏命令OpenQuery运行查询。

Lets say you name your macro mRunQueryX in Access, within the macro you define the commands: OpenQuery (with the appropiate parameters) and QuitAccess (This closes Access after it is started from the bat-file. 假设您在Access中为宏mRunQueryX命名,然后在宏内定义以下命令: OpenQuery (带有适当的参数)和QuitAccess (从bat文件启动Access后将关闭Access)。

Now from your cmd/bat-file you call/run the macro with: 现在,从您的cmd / bat文件中调用/运行该宏,并执行以下操作:

"C:\\Program Files\\Microsoft Office\\Office12\\MSACCESS.EXE" "[PathToDatabase]\\[NameOfTheDatabase].accdb" /X mRunQueryX “ C:\\ Program Files \\ Microsoft Office \\ Office12 \\ MSACCESS.EXE”“ [PathToDatabase] \\ [NameOfTheDatabase] .accdb” / X mRunQueryX

The path to MSACCESS.EXE varies with the Office-version. MSACCESS.EXE的路径随Office版本的不同而不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM