Patching steps to achieve in chef

I want to perform patching and there is a step to check whether java component is present on db or not.
For this if we fire a query then we can see that whether java component is present on DB or not so accordingly we apply the java component patch on db.

How can we do this in chef ??/
If i store the result of a query in a log then how can i check or read that log to check whether java component is present or not.

I would use guards only_if or not_if with the choosen chef resource that handles the patching
https://docs.chef.io/resource_common.html

I think you did not get my question…

Suppose on running a sql query it gave some output… say either ‘yes’ or ‘no’ and some other columns…
now i stored that log in a file…
Now i want to perform action according to that file/log… say if yes then do x and if no then do y.

How to achieve this

"For this if we fire a query then we can see thatwhether java component is present on DB or not"
Put that query into a not_if or only_if guard in a resource that handles your patching