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.