i'm making a Java program that contains a search engine feature to show the records from the database according to different criterias selected by the user out of comboboxes. I need to be able to modify the WHERE conditions of an SQL query according to what the user has selected. If he hasn't selected any value from the comboboxes then the default would be WHERE=1, if he has selected criteria from one combobox then override the variable so the 1 change it to WHERE state=oklahoma for example, and he selects 2 or more just keep concatenating them: WHERE state=oklahoma AND gender=male, and so on with as many comboboxes he sets.
i've tried to do this but i've read there are libraries that can make this easier but i don't know any, if this can be done with a library please name it and show the code to do it please