Below is my full code ..... my "prioset.jsp" is calling this file. ....
all the names that u see in the while loop like txtname+i,prio+i,exp+i..are coming from the previous jsp where the name of the textbox and combo box keeps changing ........
so the txtname+i goes into the tg_date ,then the prio+i goes into the priority and the exp+i goes into the expert string ....and in my databse corresponding to each call id i have a tg_date,priority and expert coloum ....
i have removed the String[] and now i'm using vectors to store the values through the add element ..... now if i write
for(cnt=0;cnt<v_callids.size();cnt++)
{
a_call = v_callids.elementAt(cnt).toString();
a_exp= v_experts.elementAt(cnt).toString();
a_pri = v_pri.elementAt(cnt).toString();
a_date = targetdate.elementAt(cnt).toString();
}
now if i have supposing 4 records .... so for the above code .... the a_call get the 4 id's but the a_exp,a_pri,and a_date get only ONE value ..... that means that the loop iterates 4 times for the a_call but only onece for the other three ....
The reason what came into my mind was that in my for loop the vector whose size i'm taking is v_callid's and the a_call is also storing the value v_callids.elementAt(cnt) ...... so may be that's y it's get all 4 values .... coz i couldn't notice any other reason as to y it should iterate 4 times only for "a_call"....???
If any one can find any other reason do let me know ......
Now how can i iterate through all the vectors one after another .... means ..... that i want to write a loop such that it should iterate and get the first value of the callid,tg_date,pri,expert ...then update ...then iterated through the second value ... and so on ....!!!
I have tried
String date[] = request.getParameter("txtname" + i);
But it gives a conversion error
Incompatible type for =. Can't convert java.lang.String to
java.lang.String[].
Any body has ideas to solve my problem ....!!! :roll:
my code is below .... awaiting for replies .... and yeah how do i convert a string to String[]......??? is there any built in function for it ...???
<%
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/it_support","root","");
int i = 0;
int n =0;
int ex =0;
int p = 0;
int cnt = 0;
int c =0;
String tgdate = new String();
String tg_date = new String();
String tempdate = new String();
String temp_expert = new String();
String experts = new String();
String tempexp = new String();
String pri = new String();
String temp_pri = new String();
String priority = new String();
String callid = new String();
String temp_callid = new String();
String call_id = new String();
String a_call = new STring();
String a_exp = new STring();
String a_pri = new STring();
String a_date = new STring();
Vector targetdate = new Vector();
Vector v_expert = new Vector();
Vector v_pri = new Vector();
Vector v_callid = new Vector();
Vector v_callids = new Vector();
Statement stmt1 = conn.createStatement();
Statement uprecord = conn.createStatement();
ResultSet gtcount = stmt1.executeQuery("Select * from complaints where status =0");
while(gtcount.next())
{
i = i+1;
tgdate = request.getParameter("txtname" + i) ;
targetdate.addElement(tgdate);
temp_expert = request.getParameter("exp" + i);
v_expert.addElement(temp_expert);
pri = request.getParameter("prio" + i);
v_pri.addElement(pri);
call_id = gtcount.getString("callid");
v_callid.addElement(call_id);
}
tempdate = targetdate.toString();
n = tempdate.length()-1;
tg_date = tempdate.substring(1,n);
/*-------------------------------*/
tempexp = v_expert.toString();
ex = tempexp.length()-1;
experts = tempexp.substring(1,ex);
/*-------------------------------*/
temp_pri = v_pri.toString();
p = temp_pri.length()-1;
priority = temp_pri.substring(1,p);
/*-------------------------------*/
temp_callid = v_callid.toString();
c = temp_callid.length()-1;
callid = temp_callid.substring(1,c);
/*-------------------------------*/
v_callids.addElement(callid);
out.println("The values" + ca);
out.println("The string values" + tg_date);
out.println("Total no: of Records Retreived " + i);
out.println("The string experts" + experts);
out.println("The string priority" + priority);
out.println("-------------------------------");
out.println("The string callid " + callid);
out.println("-------------------------------");
for(cnt=0;cnt<v_callids.size();cnt++)
{
out.println("Entering in loop");
a_call = v_callids.elementAt(cnt).toString();
a_date = targetdate.elementAt(cntd).toString();
a_exp = v_expert.elementAt(cnte).toString();
a_pri = v_pri.elementAt(cntp).toString();
out.println("calls" + a_call);
out.println("-------------------------------");
out.println("a_date" + a_date);
out.println("-------------------------------");
out.println("exp" + a_exp);
out.println("-------------------------------");
out.println("pri" + a_pri);
}
%>
<br><br>
<input type="submit" name="Submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>