Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- //getting parameters
- String pointName = request.getParameter("name");
- String STRpointType = request.getParameter("type");
- int pointType = Integer.parseInt(STRpointType);
- String STRlat = request.getParameter("latitude");
- double lat = Double.parseDouble(STRlat);
- String STRlng = request.getParameter("longitude");
- double lng = Double.parseDouble(STRlng);
- String coord = "Lat: " + lat + " ; " + "Lng: " + lng;
- String SQLquery = "INSERT INTO joker.point (name, coord, type_id) VALUES ("+pointName+
- ","+coord+","+pointType+");";
- Connection connection = null;
- Statement statement = null;
- String url = "jdbc:mysql://localhost:3306/joker";
- String user = "user";
- String password = "password";
- try {
- Class.forName("com.mysql.jdbc.Driver");
- con = DriverManager.getConnection(url, user, password);
- st = con.createStatement();
- //send SQLquery here
- st.execute(SQLquery);
- } catch (SQLException | ClassNotFoundException e) {
- e.getMessage();
- } finally {
- try {
- if (st != null) {
- st.close();
- }
- if (con != null) {
- con.close();
- }
- } catch (SQLException ex) {
- ex.getMessage();
- }
- request.getRequestDispatcher("/admin_point_added.jsp").forward(request, response);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement