Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JSP Interest »

Problem with JSP/JDBC insert

Campano, Troy

2003-08-29


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 listserv@(protected)".
For digest: mailto listserv@(protected)".

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


©2008 junlu.com - Jax Systems, LLC, U.S.A.