Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var oTable;
- $(function(){
- oTable = $('#data').dataTable({
- "sDom": 'TC<"clear">lfrtip',
- "processing": true,
- "serverSide": true,
- "bJQueryUI":true,
- "sPaginationType": "full_numbers",
- "ajax": {
- url: 'worldCheck',
- type: 'GET'
- },
- (...)
- });
- });
- @WebServlet("/worldCheck")
- public class worldCheck extends HttpServlet {
- private static final long serialVersionUID = 1L;
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- int rows;
- JSONObject obj = new JSONObject();
- JSONArray back = new JSONArray();
- try{
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/check","****","****");
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT UID,LastName,FirstName,BDay FROM worldCheck");
- ResultSetMetaData meta = rs.getMetaData();
- rows = meta.getColumnCount();
- while(rs.next())
- {
- JSONArray array = new JSONArray();
- array.put(rs.getString("UID"));
- array.put(rs.getString("LastName"));
- array.put(rs.getString("FirstName"));
- array.put(rs.getString("BDay"));
- back.put(array);
- }
- obj.put("data", back);
- obj.put("draw", 1);
- obj.put("recordsTotal", rows);
- obj.put("recordsFiltered", rows);
- response.setContentType("application/json");
- PrintWriter out = response.getWriter();
- out.print(obj);
- con.close();
- }catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- doGet(request, response);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement