Skip to content

Instantly share code, notes, and snippets.

@muhammadfarras
Last active August 23, 2022 04:00
Show Gist options
  • Save muhammadfarras/2c80e35100548873b6783d9208f8ef6d to your computer and use it in GitHub Desktop.
Save muhammadfarras/2c80e35100548873b6783d9208f8ef6d to your computer and use it in GitHub Desktop.
Split Select Query
<%--
Document : AjaxSCBC
Created on : Jul 5, 2022, 10:02:02 AM
Author : Muhammad Farras Ma'ruf
--%>
<%@page contentType="application/json" pageEncoding="UTF-8"%>
<%@page import="dbase.DBBIC"%>
<%@page import="dbase.DBconnection"%>
<%@page import="java.io.IOException"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="java.util.logging.Level"%>
<%@page import="java.util.logging.Logger"%>
<%@page import="javax.servlet.RequestDispatcher"%>
<%@page import="javax.servlet.ServletException"%>
<%@page import="javax.servlet.http.HttpServlet"%>
<%@page import="javax.servlet.http.HttpServletRequest"%>
<%@page import="javax.servlet.http.HttpServletResponse"%>
<%@page import="javax.servlet.http.HttpSession"%>
<%@page import="model.DataBIC"%>
<%@page import="com.google.gson.Gson"%>
<%
// Maximum total data that avail to show
final int maxData = 25000;
// set offsetpage based on page numbers
int offsetPage = request.getParameter("offset") == null ? 0 : Integer.parseInt(request.getParameter("offset"));
// create connection
DBconnection dbConn = new DBconnection();
DBBIC db = new DBBIC(dbConn.getConnection());
// get data from data base by provided paremeters
List<String[]> bic = db.getPagesBicAjax((offsetPage * maxData), maxData);
// convert datas to json
String jsonResult = new Gson().toJson(bic);
// show the json
out.print("{\"data\" : " + jsonResult + "}");
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment