Approach: We have a JSON file containing data in the form of an array of objects. For each record in the JSON array retrieve the key-value pairs using the get method and set value to the appropriate bind variable of the PreparedStatement using the setXXX() methods. @Rakesh: What do you mean "if am not using the pair in future"? From my UI via ajax I am getting an JSON data Which I am trying to insert into my data base, about which I have no idea how can i do that, I know how to insert something in database using prepared statements but here in JSON case I am totally confused, This is my JSON which I am getting in my doPost, Do i need to parse this JSON, how will i do ps.setInt(index, 0);, I am not getting any idea, As @Anjana Senanayake answer I am doing like this, But it is throwing error at JSONObject innerObj = new JSONObject(jsonArray[0]); error is The type of the expression must be an array type but it resolved to JSONArray, You have several options here. Better parse the JSON and insert the data into the table field wise. What are the differences between a HashMap and a Hashtable in Java? [closed], desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem, Microsoft Azure joins Collectives on Stack Overflow. How to import JSON into MongoDB using Python. Agree create a clob column in table and store it. For more information on bulkWrite, you can visit the documentation page. Servlet is a Java class which responds to a particular type of How to insert data into a table with auto-incremented columns using JDBC? This array list is then written into the database using the bulkWrite function. Connect and share knowledge within a single location that is structured and easy to search. Before you can write to a database you need to make sure that you have a database configured. Refer to the section above for more information on
John Beck Aecon Net Worth,
Articles H
how to insert json data into database using java