java - confused with the design of servlet -


I want to create servlet that gets the data in Jason format and stores data in the database. When I send data to the servlet via HTTP request, it will establish a connection with the table, create tables, and store the data. The code should be made only for the first time to create connections and tables. I am not able to design code which is making connections and tables for the first time and is not able to store the data in the remaining time

My code is as follows: -

  Public Class Master Protects Zero DoPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {handle (request, response); } Private Zero Handle (HTTPPervlet Request, HTTP Servalar Response Resp) {JSONObject jsonObject = null; {Try (if "req.getMethod") is equal to ("post") {try {string jsonString = extractJsonBody () / * Create code for connection with database table archive data * /} (Exception e) {System. Out.println ("Jason in bad format"); }}}  

You can use the servlet's init method for connection And check the creation of the table that the table is not present in the database.

.init (config); If the `` / / database is not present in DB, create a database connection and table creation with the condition <

Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

c# - WPF Expander overlay used in ItemsControl -

class - Kivy: how to instantiate a dynamic classes in python -