'Fetch rows based on value

I have a value abc stored in string I like below -

String i='abc'

I want to fetch all rows from database which has value abc buy using below query-

Select * from db where docname=i;

I don't want to put 'abc' directly. Is there a way to do it?

Note:- I am writing this query in Java eclipse



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source