How to execute update query in jsp




















Here I am using MySql as Database so I have downloaded the jar with name as : "mysql-connector-java Create a Database am using MySql as backend name as "javaee". Create a table in "javaee" database as "customer". Populate the table user with some data of your own , if not run the four insert queries stated below - insert into customer values 'Jonty','Magic','jonty magic. Create a Servlet. It will perform necessary update query. The code for servlet is shown below - package com.

IOException; import java. PrintWriter; import java. Connection; import java. DriverManager; import java. ResultSet; import java. SQLException; import java. Statement; import javax.

ServletConfig; import javax. ServletException; import javax. WebServlet; import javax. HttpServlet; import javax. HttpServletRequest; import javax. Newer Post Older Post Home. Subscribe For Free Video Tutorials. Search This Blog. How to use Qualifier annotation in Spring Framewo How to turn on Auto Scanning of Spring Components How to calculate Trigonometric functions values in How to turn on Annotations in Spring Configuration How to convert degrees into radians and radians in How to calculate Square root and Cube root of a nu How to use InitializingBean and DisposableBean int How to display request parameters in a JSP coming How to use init-method and destroy-method attribut How do I add an element and get an element in an A How to provide constructor initialization to a bea Instead of returning a collection of rows, the executeUpdate method returns the number of rows affected by the SQL command it executes.

The signature of the executeUpdate method is:. Provide this method a single parameter of type String , containing the SQL command that you wish to execute. The example that follows demonstrates using the executeUpdate method to add a row to the emp table. NOTE: the following example is not a complete application, only a method - the samples in the remainder of this document do not include the code required to set up and tear down a Connection. However, this is not the cause of the exception.

You will need to examine the full stacktrace from the exception Again, this is easier if you can log it from a servlet class. Without that, it is impossible to know what the problem is. Asif's comment may solve your problem: In your query, you have a column name that contains a space. Column names with spaces are problematic. Check the escape syntax for your DBMS -- or, if you can, change the column name to something without spaces.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to update query from jsp? Ask Question. Asked 9 years, 8 months ago. Active 8 years, 3 months ago.



0コメント

  • 1000 / 1000