protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String connectionURL = "jdbc:mysql://localhost/csv";
String url = request.getParameter("WEB_URL");
Statement stmt = null;
Connection con = null;
try {
String filename = "SearchCases.csv";
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(connectionURL, "root", "root");
stmt = con.createStatement();
String qry = "select * from user_managecase";
ResultSet rst = stmt.executeQuery(qry);
response.setContentType("text/csv");
response.setHeader("Content-disposition", "attachment; filename=" + filename);
resultSetToCsv(rst, response.getWriter());
} catch (Exception e) {
e.printStackTrace();
} finally {
con.close();
}
}
|