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>

[596 byte] By [ZafarAliKhana] at [2007-10-3 4:52:16]
# 1
String prod_detail[]=req.getParameter("prod_detail"); give it like thisString[] prod_detail=(String[])req.getParameter("prod_detail");
yashyash1234a at 2007-7-14 22:57:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
thanks for your reply but its giving error "Inconvertable type"
ZafarAliKhana at 2007-7-14 22:57:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
plz check yr req.setParameter("prod_detail") method in which u set the data if possible send me
yashyash1234a at 2007-7-14 22:57:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

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>");

}

}

}

ZafarAliKhana at 2007-7-14 22:57:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
> String[]> prod_detail=(String[])req.getParameter("prod_detail");I think you mean:String[] prod_detail = req.getParameterValues("prod_detail")The regular getParameter() only returns a single StringBrian
brian@cubik.caa at 2007-7-14 22:57:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...