There is something wrong with your idea. You should open the database, find the name of the corresponding class, and then display it.
sql="select * form... where ...=getValue()"
This sentence just means a query, you have to write it according to your code.