This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Java in General and the fly likes need help in connection  performance... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "need help in connection  performance..." Watch "need help in connection  performance..." New topic

need help in connection performance...

Raza Mohd
Ranch Hand

Joined: Jan 20, 2010
Posts: 247

hi all,
In my application the scenario is ..
1: Parsing of Xls file which retrieves the values from Xls and set them to the Bean.
2: After parsing , each record is sent to validation with the records present in another table if the data is validated it is inserted to the new table .
3: So each time i insert the record , connection is opened and closed..the process take time ...due to that it says time out on web ..
4: File is having 4000 need a optimum solution

Can anybody tell me the possible solution so that i can handle this..

Thanks in advance..


Good luck!!
A small leak can sink a Gigantic ship.>
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Use 1 connection for validating and inserting instead of 4000?

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Raza Mohd
Ranch Hand

Joined: Jan 20, 2010
Posts: 247

can i use stored procedure to write comma delimited string to table ?
Raza Mohd
Ranch Hand

Joined: Jan 20, 2010
Posts: 247

i need to write comma delimited data to a column and then need to left join with other table ..
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

If you're using a PreparedStatement, use a single Connection and insert the records in batches (see the API for PreparedStatement addBatch method)
4000 isn't a huge number of inserts.
Raza Mohd
Ranch Hand

Joined: Jan 20, 2010
Posts: 247

i am using EJB to insert the records rather than prepared statement.
I agree. Here's the link:
subject: need help in connection performance...