Reputation: 145
I have an Access DB, to make the job easier, I did the queries into DB. How I can take data from the query instead of from tables?
To take data from tables I used this code:
Table table = db.getTable("matchTable");
Cursor cursor = CursorBuilder.createCursor(table);
while (cursor.findNextRow(Collections.singletonMap("idMatch", 15))) {
Row row = cursor.getCurrentRow();
...
}
Upvotes: 4
Views: 3030
Reputation: 123419
According to the Jackcess FAQ (specifically, here):
Can Jackcess execute SQL queries?
As of the 1.1.19 release, Jackcess has the ability to read the Queries saved in an Access database (i.e. interpret the data stored in the system Queries table). However, Jackcess does not have the ability to execute these Queries.
It means that Jackcess can retrieve the SQL code associated with a saved query in Access, but Jackcess cannot execute that SQL code (or return its results).
In other words, if we have a saved query in Access named [MySavedQuery] then Jackcess can retrieve a String
that contains the SQL command, e.g.,
SELECT * FROM Customers WHERE City='wherever'
but Jackcess cannot execute that command to actually return the results of that query. Also, the Jackcess method db.getTable()
can open an Access table, but it cannot open a saved query as if it was a table.
However, UCanAccess can execute saved Access queries and return their results. That is, UCanAccess can do
SELECT * FROM MySavedQuery
Upvotes: 3