This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "performance issue of Vector" Watch "performance issue of Vector" New topic

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

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 "


can u pls help me out???

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.


SCJP 1.4
I agree. Here's the link:
subject: performance issue of Vector
Similar Threads
Regarding vector
When Session Closed Data Will be Lost in Hibernate
How to sort different attributes in Vector?
How to access data?