problem with multiple insert into DB
String[] product=req.getParameterValues("prod");
if (product != null)
{
for (i=0;i<product.length;++i){
product=product;
}
}
//this works well
String prod_detail[]=req.getParameter("prod_detail");//gives message"Incompatible Type" why?
if (prod_detail != null)
{
for (i=0;i<prod_detail.length;++i){
prod_detail=prod_detail;
}
}
plz let me know the solution that why its giving error while am getting the prod_detail
thanks in advance>
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class post_co1 extends HttpServlet{
Connection cnn;
Statement stm;
ResultSet rs;
public post_co1(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cnn=DriverManager.getConnection("jdbc:odbc:gsw");
stm=cnn.createStatement();
ResultSet rs;
}catch(Exception e){
System.out.println("DB is not Connected");
}
}
public void doPost(HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
int i;
String coname=req.getParameter("coname");
String estyr1=req.getParameter("estyr1");
String estyr2=req.getParameter("estyr2");
String estyr3=req.getParameter("estyr3");
String estyr4=req.getParameter("estyr4");
String estyear=estyr1+estyr2+estyr3+estyr4;
String emp1=req.getParameter("emp1");
String emp2=req.getParameter("emp2");
String emp3=req.getParameter("emp3");
String emp4=req.getParameter("emp4");
String emp=emp1+emp2+emp3+emp4;
String turnover=req.getParameter("turnover");
String cointro=req.getParameter("cointro");
String[] product=req.getParameterValues("prod");
if (product != null)
{
for (i=0;i<product.length;++i){
product=product;
}
}
String prod_detail[];
for (i=0;i<prod_detail.length;++i){
prod_detail=req.getParameter("prod_detail");
}
try{
stm.executeUpdate("insert into company(co_name,co_registered) values('"+coname+"','"+0+"')");
stm.executeUpdate("insert into company_info (co_id, co_establishment_year,co_number_of_employee,co_annual_turnover,
co_introduction) values (( select co_id from company where
co_name='"+coname+"'),'"+estyear+"','"+emp+"','"+turnover+"','"+cointro+"')");
for(i=0;i<product.length;i++){
stm.executeUpdate("insert into company_product_category(co_id,Product_category) values((select co_id from company where
co_name='"+coname+"'),'"+product+"')");
}
for(i=0;i<product.length;i++){
stm.executeUpdate("insert into product(co_id,Pro_name) values((select co_id from company where
co_name='"+coname+"'),'"+prod_detail+"')");
}
}catch(Exception e){
out.println("><h1>Please try later on</h1>");
}
}
}