Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how best to process sql data

Status
Not open for further replies.

ZagorTenay

Programmer
Jul 1, 2005
6
TR
I am working on an application that uses sql data (tomcat and MS sql server). There will be about 15-20 simultaneous clients. I would like to know if my logic makes any sense. I am very new to java, any kind of help would be great..

To access the sql server, I am going to write a bean that opens a connection, gets/deletes/inserts/updates the data and if there is any data to be returned, puts the data into an array(??) and returns the array, then closes the connection.

My question is, what is the best way to pass the data from the bean to the servlet? The queries are all very different... (How to pass a 10 column data into a servlet) The same goes for making an update query - pass the changed data back to the bean and execute..

Is it at all possible to work with a resultset?

Thanks a lot..
burhan
 
Remember that working with a Resultset leaves the connection open until you close it.

I bet for the Resulset way + a DB connection pool. If you pass the data to an array, you can save the pool, but if the query returns a big amount of data, the performace would decrease.

Cheers,
Dian
 
If it is possible to work with a resultset, how do you pass it to the servlet from the bean? I tried.. it would not work..
The problem had something to do with having the connection in the bean not the servlet and so I could not pass the resultset.

the resultset does not contain the data does it?

Cheers,
burhan
 
For the 'get' operation, return the data from the data access bean using a 'Data Transfer' class. This is simply a POJO which conforms to the JavaBean spec and contains all the data requested.

You need to be aware of the performance hit which Dian mentioned, though. If the type of queries you are running are likely to return large data sets, then you might be advised to implement some 'data paging' mechanism whereby only a portion (or 'page') of data is returned and the client has the option of requesting further pages (just like the way that Google works).

Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top