简体   繁体   中英

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. When I try to see sql code of query

The SQL statement could not be executed because it contains ambiguous outer joins

alter is shown. So i must call and run queries. I tried to open and run spesific queries by cmd .bat file. However I cannot find any script for solution. Is there any sql code to run any query from another query? 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 .

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.

Now from your cmd/bat-file you call/run the macro with:

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

The path to MSACCESS.EXE varies with the Office-version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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