New to Server Side
New to Server Side

Hi Team,
I am new to Springs as well as for this feature. Here I want to know how to implement this feature. Before asking the question here is my requirement
User enters a SQL query
I will register the DB using Spring JDBC
Execute the query
Return the results to the JSP
Now using JSTL tags displaying the results in DatatTable
But the above steps are taking too much of time to render the results in JSP. I have seen many posts about the perfomance and I found that I need to implement the server side functionality using DataTable.
But, here I need the following clarifications
I can call a spring controller with the Ajax source and I can pass the SQL arguement
Here I am not sure how can I execute the query and send a response to DataTable
And also, let's say if 100000 records has been requested then clicking on CSV generates the excel sheet of 10000 records or only the viewable records?
Please help me out.
Thanks.