optimizing java code related to beans and jdbc

HI,

I have a question about optimizing Database Hits from a Bean.

I have a java bean that is currently in request scope.

All methods in the bean returns Vector which contains the contents of different JDBC queries - Several Select Statements.

After the bean is instantiated all the methods are called separately

ie Vector v1=MyBean.getVector1(a, b);

Vector v2=MyBean.getVector2(b);

Vector v3=MyBean.getVector3(b,a);

all the methods have something in common which is that they all accept a b or c as parameters in different orders and combinations.

As a result each page of the application is slow.

Apart from Optimizing queries and table structure with indexes etc, I'm under the impression that I could optimize this.

How would you guys optimize the Bean Code?

I'm under the impression that since i use this same bean on every page (although the parameters are different for every page because they are passed in from the querystring ), I am better off putting the bean in session variable .

What else would you guy do to improve the performance -- interms of java code.

Currently it is using java beans (not enterprise java beans) on a weblogic server with oracle 8 i database.

I am using SQL statements instead of stored procedures - the sql statements are in the

stephen

[1400 byte] By [stephensutherland] at [2007-9-26 2:09:55]
# 1

Switching your bean to a session bean can help, if that change is possible. Using arrays, rather then Vectors would certainly help. Typically, this slowness is not caused by the database hits, so much as the object creation time. Vectors can be inefficient, from a system resource perspective. It seems like you are creating an object for each element in the result set. The best way to improve speed, is to minimize the amount of objects you are creating: only create objects that are needed, only create them as many times as necessary and use objects that are as light as possible. I would look at what Objects you are displaying versus what you are returning: do you need that many objects? Are you returning heavy objects in these Vectors, like some business objects, rather then Strings or primitive data types that could provide the same information? Maybe a window exists for removing some of these Objects, or using lighter weight objects.

rvflannery at 2007-6-29 9:00:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...