Ravinder Rana

Greenhorn
+ Follow
since Dec 07, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Ravinder Rana

Hi all,

Just want to know if ThreadPoolExecutor.execute() method ensures that if a idle thread is available in thread-pool or we have not reached the maximum thread limit yet, it will execute the submitted task immediately?

Thanks
close() method of resultset, statement and connection throws SQLException, so you need to put that also in a try-catch block. Before calling close it's better to check that they are not null, otherwise you will get a NullPointerException. So your finally block should look like this:


Hope this helps.
Do you mean that it should return all the strings which contain "srin" string in it? If yes, following is the code which does the same:

17 years ago
You can do this using server push. For more information on server push visit Push Servlet or do a google search. I have used server push a long time back in a project. If you have any doubt, regarding implementation, please get back to me.
17 years ago
Thanks everyone for helping me out. All comments helped me in better understanding the concepts. Now I changed my design a little bit and that I think is performance wise scalable.

Once again thanks a lot
17 years ago
Consider the following code:



Now, suppose 10 threads are concurrently executing this method. How many instances of String "Teacher", "Prof", and "Lecturer" will get created - 3 or 10*3??
17 years ago

create a StringReader which can then be used to create a LineNumberReader or BufferedReader.



But, the string will still remain in memory, so what's the benefit of using this?
17 years ago
Thanks Ulf I have updated my code to support line breaks or quotes inside of text.

William, I have read the whole data at once because the data is not in a csv file but am getting this from some other program and I have no control over it. So can you suggest some String handling optimization techinques, for this particular case.

Thanks
17 years ago
Thanks Ulf and William for your comments. Ulf, I have finished the coding part of it and found that it's working fine for csv data containing 5000 rows with 50 cells each but as the no. of rows increases the application slows down and sometimes it also throws OutOfMemoryException. I think it's because I am creating a lot of objects. Following is the part of code I have written:



So, I am creating customInfo and phonesNos objects for each row of csv data.
Can you tell me how to avoid this thing?

William, you are right that database writing operation are going to be slowest, so to avoid this I am using bulk insert approach. This saves me the no. of database calls.

Regards,
17 years ago
Hi all,

I am working on a project and facing some performance problems. I need to parse csv data and store that data in various tables in a data base. Some of the fields(Max 5-8) in csv corresponds to same database fields, so before inserting them in DB I need to store them in a list or array.

There are more than 10,000 rows in csv, so I need to optimize this thing. So I need to know which is the best thing to use in this case, a simple array or an array-list.

Any help/suggestions or links are welcome.

Thanks
17 years ago
Hi All,

I need some help from you guys regarding bulk update. The scenario is as follows:

I have 3 tables in my DB: Person, Person_Phone_Numbers and Person_custom_info

Person table has a id(AUTO_INCREMENT)and Person_Phone_Numbers and Person_custom_info tables has this as their foreign key.

The no. of records which I have to insert at a time will be somewhere between 50 to 200, so I want to do a batch insert i.e. first insert all Person info followed by Person_Phone_Numbers and Person_custom_info.

Now the problem is, to insert data in Person_Phone_Numbers and Person_custom_info tables I need the Person ID value's. Is there a way to get these values? I am using MySQL as database.

All inputs appreciated.

Thanks
Yes, the container gives us an implementation of these interfaces. Just think for a moment, if they doesn't implement these interfaces how can we call the methods using these interfaces?
17 years ago
There are two signatures of init() method: init(ServletContext) and init().
The container creates an instance of ServletContext and passes it's reference for our use. We need to store this instance as a reference. The HttpServelt class does this for us and then it calls init() from that method[init(ServletCOntext)] itself. So we don't need to override init(ServletContext) or init() method to get the instance of ServletContext object.
17 years ago
You can do this using Java mail API. To learn more about it, follow this link Java Mail API
17 years ago
Go through this link: Directory Structure
17 years ago