Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Cannot save data to database ...! May I know why?

843836Sep 10 2003 — edited Sep 13 2003
Hello ppl. I am new to this site and in dire need of help

I have this coding where the user inputs the number of records he is to input and another page will load with that number or data rows.

But when i do a sql statement to save the data it says that there's syntax error in the INSERT INTO statement whereas i don't think that there is any.

Here's the code
<%
	Connection con = null;
	Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
	con = DriverManager.getConnection("jdbc:odbc:Prod2","","");
	java.sql.Statement stm = con.createStatement();

	String num = (String)session.getValue("num");
	int newNum = Integer.parseInt(num);

	for (int i=0; i<=newNum; i++)
	{
		String todate     = request.getParameter("todate");
		String week       = request.getParameter("week");
		String customer   = request.getParameter("customer");
		String model      = request.getParameter("model'+i+'");
		String lotNum 	  = request.getParameter("lotNum'+i+'");
		String lquan  	  = request.getParameter("lquan'+i+'");
		String insp   	  = request.getParameter("insp'+i+'");
		String rej 		  = request.getParameter("rej'+i+'");
		String area 	  = request.getParameter("area'+i+'");
		String loc		  = request.getParameter("loc'+i+'");

		String sql = "INSERT INTO OQA(Date,Week,Customer,Model,Lot_No,Lot_Qty,Inspected_By,Reject_Desc,Area_Concerned,Location) VALUES ('"
		+todate+"','"+week+"','"+customer+"','"+model+"','"+lotNum+"','"+lquan+"','"+insp+"','"+rej+"','"+area+"','"+loc+"')";
		stm.executeUpdate(sql);
	}
	stm.close();
	con.close();
%>
Can anyone help me..please


Regards,
Ctzen
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 11 2003
Added on Sep 10 2003
8 comments
926 views