Dynamic SQL is the
opposite of stored procedures. What you do is to use a StringBuffer to create your SELECT statement, appending your SORT BY and ORDER BY clauses. Create a PreparedStatment, passing your StringBuffer as the statement to execute. Then just call executeQuery().
If your shop requires that all SQL be performed via stored procedures, then
you should talk to your DBA and see if they have any suggestions. Otherwise, you might want to write a small utility that goes out to the database, grabs the metadata for the table you're querying, and generates the stored procedure with the IF statements for every column. At least that way, you don't have to go in and update the SP by hand every time the table schema changes.