Are you familiar with DatabaseMetaData and ResultSetMetaData? They can allow you to read column names and/or filter information not known until runtime. For example, you can use them to provide the user with a list of columns in a table, thereby allowing them to select the columns they'd like to use for a query.
As a side node be extremely careful with 'dynamic query builders'. For medium and large database systems, giving users the ability to run arbitrary, possibly untested queries is *extremely* dangerous. Historically, the more open a query builder is within an application, the stronger likelihood the user can execute a query that grinds the entire database to a halt. Alternatively, I find its a better practice to offer clients a list (or report) of most desired queries that you can
test and manage.