java - I cannot get the jsp to execute a SQL update statement -


I am trying to input a jsp user from a form on "update.jsp" and to update An update statement is running in the database entry and the result is displayed on "display.jsp" using eclipse as my IDE, and Oracle as my database server - first, I have successfully selected a selected statement (a test ), So I'm sure There is nothing wrong in relation to the DB - it "update.jsp" (form) is used to code the

  & lt; Form action = "display.jsp" & gt; & Lt; Label & gt; Semester: & lt; Select name = "semester_form" & gt; & Lt; Option selected = "semester" & gt; Select semester & lt; / Options & gt; & lt;% // public string input_semester = semester; & Gt%; & Lt; Option value = 'spring' & gt; Spring & lt; / Options & gt; & Lt; Option value = 'difference of January' & gt; January gap & lt; / Options & gt; & Lt; Option value = 'fall' & gt; Fall & lt; / Options & gt; & Lt; Option value = 'Summer all' & gt; Summer All & lt; / Options & gt; & Lt; Option value = 'summer' & gt; Summer 00 & lt; / Options & gt; & Lt; Option value = 'summer 02' & gt; Summer 02 & lt; / Options & gt; & Lt; Option value = 'Summer01' & gt; Summer01 & lt; / Options & gt;   

And here is the database that I used to create the database

  CREATE TABLE SEMESTER_SCHEDULE_READER (SEMESTER_ID VARCHAR2 (2) NULL, START_DATE DATE NULL, END_DATE DATE NULL, SEMESTER_NAME VARCHAR2 (25) NULL, Semester VARCHAR2 (8) NULL)   

And now it is the "display.JSP" code

  connection conn = Null; Try {// 1. Load driver class. forName (driver); // myusername and mypassword have been declared in the file named username.jsp / 2. Connection URL // Define 3. Connection Conn = Install DriverManager.getConnection (url, myusername, mypassword); // 4. Create a statement object statement stmt = conn.createStatement (); Ready placement pstatement = faucet; Int updateQuery = 0; // 5. Execute a query string semester = request.getParameter ("semester_form"); session.putValue ("semester_form", semester); String start_date = request.getParameter ("startDate_form"); String and_date = request.gate operator ("endadform"); // ResultSet rs = stmt.executeQuery (choose * SEMESTER_SCHEDULE_READER * where semeStER_NAME = '"+ semester +"' '); Conn.setAutoCommit (wrong); Prinamset rs = stmt.executeQuery ( "Update SEMESTER_SCHEDULE_READER set START_DATE = to_date ( '" + start_date + "', 'DD-MON-YY' Where semester =" + semester + " ''); conn.commit ()); // Print a welcome message. Printline ("& lt; H1> You have successfully updated semester schedule & lt; / H1> 
" // "table and column header Print Start Autkprintlain ( "& lt; table width = 600 Selspaking = \" 0 \ "CELLPADDING = \" 3 \ "border = \" 2 \ "& gt;"); Out.println ( "& lt; TR & gt; & lt; TH> Semester Name & lt; / TH & gt; & lt; TH & gt; Start Date & l t; / TH> & lt; TH & gt; end date & lt; / TH & gt; & lt; / TR & gt;); // 6. Process Results // Column names and data types are matched to DB columns (rsnext ()) {out.println ("& lt; tr & gt;"); out.println ("& lt; TD & gt;" + rsgetstring ("SEMESTER_NAME") + ""); out.println ( "& lt; td & gt;" + rsgetstring ( "START_DATE" + "& lt; / TD & gt;"); out.println ( "& lt; TD & gt;" + rsgetstring ( "END_DATE "+" & lt; / TD & gt; "); out.println (" & lt; / tr & gt; ")}} Out.println (" & lt; / table & gt; ");} Hold ( Eclipse e) {// Capturing exception, such as no connection or // query has not been properly set out. Println ("SQLException:" + e.getMessage () + "& lt; BR & gt; ; "); while ((e = e.getNextException ())! = null) out.println (e.getMessage () +" & lt; BR & gt; ");} catch (Clasnotfound Exception e) {out. println ("Klassnotfound exception:" + E. Gate Message (+ ""
"");} Finally {// 7. Close the connection; Clean the resources if (conn! = Null) {try {conn.close ();} hold (ignoring the exception) {}}}%>

  resultsetset rs = stmt.executeQuery (...)   

int result = stmt.executeUpdate (...)

executeQuery query (select) Are executing, but when code will replace db (insert, update, delete), the code is used. executeUpdate is used.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -