Based on your previous posts, it sounds like you're trying to do a lot of things without really studying any of the basics.
Yes, you can easily create a GUI in Java that:
a) Allows the user to type in a SQL query
b) Queries the database (using exactly the JDBC stuff you asked
about in earlier posts)
c) Displays the results in a query (for example, in a Swing JTable)
Strong suggestion: check out Bruce Eckel's Most Excellent "Thinking in Java" (I prefer book format, but it's also freely available on-line):
http://www.mindview.net/
IMHO .. PSM