Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 13th, 2004, 10:30 AM   #1
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
I am using a servlet etc fine but when 2 threads access this same class...

package AIS;

import java.sql.ResultSet;
import java.sql.Statement;
import java.util.*;
import connectInfo.dbConnect;

public class MBMStorage implements java.io.Serializable{

//	private Vector prodid = new Vector();
	private Vector chld = new Vector();
	private Map mp;
	private boolean isEmpty = true;
	
	public MBMStorage(){};
	
	public synchronized void fill(){
 
 mp = new HashMap();
 String sqlString = "SELECT BPROD,BCHLD FROM V611BPCSFL_MBM ORDER BY BPROD";
 String first = "";
 String last = "";
 try{
 	
 	dbConnect con = new dbConnect();
 	Statement stmt = con.getCon1(); 
 	ResultSet rs = stmt.executeQuery(sqlString);
 	
 	while (rs.next()){
  first = rs.getObject(1).toString().trim();
  if (first.equalsIgnoreCase(last)){
  	chld.add(rs.getObject(2).toString().trim());	
  }else if(last.equals("")){
  	chld.add(rs.getObject(2).toString().trim());	
  }else if(!last.equalsIgnoreCase(first)){
  	Vector temp = (Vector) chld.clone();
  	mp.put(last,temp);
  	chld.clear();	
  	chld.add(rs.getObject(2).toString().trim());
  }
 
  
  last = first;
 	}
  
 }
 catch(Exception e){
 	e.printStackTrace(); 	
 }
 isEmpty = false;
	}
 

	public Vector getChld(String pNo){
 Vector toReturn = new Vector();
 if(mp.containsKey(pNo)){
 	return (Vector) mp.get(pNo);
 }else{
 	return toReturn;
 }
	}
	
	
	public boolean getHasChld(String pNo){
 if(mp.containsKey(pNo)){
 	return true;
 }else{
 	return false;
 }
	}
	
	public boolean isEmpty(){
 return this.isEmpty;
	}
 


}

it has a headache and nothing happens, yet when 1 class uses it, it takes about 5 minutes to load all ther records and use the class.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:17 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC