Well I assumed that but it's only printing out the "row was inserted" message once. :-(
If I have multiple inserts going on, should I be doing stmt = conn.createConnection() stmt.executeUpdate(); stmt.close() For each statement...or just the stmt.executeUpdate() part? Thank you! ~ Troy Campano ~ -----Original Message----- From: Hyne, David [mailto:[EMAIL PROTECTED] Sent: Friday, August 29, 2003 2:58 PM To: [EMAIL PROTECTED] Subject: Re: Problem with JSP/JDBC insert The code is correct as is. It could be getting in array.size() of > 1 and insert more than one time ;-) You may change to PreparedStatement() instead and try it. But define it outside your For-loop and just clear parameters upon new line(s). And do not close it inside the loop. -----Original Message----- From: Campano, Troy [mailto:[EMAIL PROTECTED] Sent: Friday, August 29, 2003 11:15 AM To: [EMAIL PROTECTED] Subject: Problem with JSP/JDBC insert Hello, I'm having a problem doing a SQL insert from my JSP. The below code gets executed once, however it's doing 2 INSERTs. When I comment out "stmt.executeUpdate(sSQL);" then it only INSERTs once. So I assume the "stmt = conn.createStatement" is executing the SQL as well, but how would it know what SQL to execute? Can anyone see what I'm doing wrong? Thank you! ~ Troy Campano ~ //begin code for(int counter = 0; counter < AddDbaArray.length; counter++) { sSQL = "INSERT INTO inv.jn_db_user_t (db_id, user_id, user_typ_cde, row_crt_dte, row_upd_dte, row_dlet_ind) "; sSQL = sSQL + "VALUES ('" + AddDbaArray[counter] + "','" + user_id + "','0',sysdate,sysdate,'N')"; displayHTML = displayHTML + sSQL; stmt = conn.createStatement(); stmt.executeUpdate(sSQL); stmt.close(); stmt = null; out.println("The row was inserted"); } //end code ======================================================================== === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com ------------------------------------------------------------------------ ------ This email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else, unless expressly approved by the sender or an authorized addressee, is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action omitted or taken in reliance on it, is prohibited and may be unlawful. If you believe that you have received this email in error, please contact the sender, delete this e-mail and destroy all copies. ======================================================================== ====== ======================================================================== === To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com