aspose file tools*
The moose likes Java in General and the fly likes performance issue of Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "performance issue of Vector" Watch "performance issue of Vector" New topic
Author

performance issue of Vector

Ramesh Shanmugam
Ranch Hand

Joined: Sep 13, 2004
Posts: 132
Hi all,

I have a webpage. where i am displaying my data in a jsp page. i have used Vector to fetch the data from the databases.

But once when more number of users try to access the page.. the Vector doesnt work.

is it a better or good way to use vector in webpages.
pls reply


Ramesh Shanmugam - SCJP 1.5
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
You should use an ArrayList instead of a Vector but that shouldn't cause problems. What exactly does "does not work" mean"? How are you using the Vector? Could you give us a code snippet or two?


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Ramesh Shanmugam
Ranch Hand

Joined: Sep 13, 2004
Posts: 132
Sir,

I have a JSP page. from there i am accessing a java File. There i will fetch the Data's from the DB and set it into a Vector and pass the same to the JSP page for the Display.

The method in the java file is not synchronised.

when the page gets more number of hits .. then the array returned in empty
vector[] and so i am getting a exception in the JSP page.
(why bcos i am accessing the Vector in the JSP to show up data's) so when a null vector is access using vector.get(i) (where i is loop variable)

i am getting "java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1 "

Exception

can u pls help me out???

Thanks
Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
I dont think it is a vector performance issue. can you pls paste the code snippet and a scenario in which it fails???
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Is the Vector static or an instance variable of the servlet? Without some code snippets I don't think we will be able to help.
Giovanni De Stefano
Ranch Hand

Joined: Aug 17, 2004
Posts: 144
...just forget Vector, use ArrayList instead, and post your code.

Giovanni


SCJP 1.4
 
jQuery in Action, 2nd edition
 
subject: performance issue of Vector