public boolean sellStocksOrFunds(String accountID, String investSymbol, int type, int numberOfShares) {
		int dueNumber = numberOfShares;
		boolean flag = true;
		
		Timestamp targetTime, todayTime;
		int ownNumber, toSell, shortOrLong;
		double crtPrice, amount, prevPrice, gainOrLoss;
		Statement s;
		
		TransControl control = new TransControl();
		SymbolControl control2 = new SymbolControl();
		
		java.util.Date utilDate = new java.util.Date();
	    java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
	    todayTime = new Timestamp(utilDate.getTime());
	    
	    crtPrice = control2.getCrtPrice(investSymbol, type);
	    
	    try {
			con.setAutoCommit(false);
			s = con.createStatement();
	    
			while (dueNumber > 0) {
				targetTime = getEarlestTimestamp(accountID, investSymbol);
				ownNumber = getRecordNumOfShares(accountID, investSymbol, targetTime);
				prevPrice = getRecordPrice(accountID, investSymbol, targetTime);
				
				if (ownNumber >= dueNumber) {
					toSell = dueNumber;
				} else {
					toSell = ownNumber;
				}
				dueNumber = dueNumber - toSell;
				ownNumber = ownNumber - toSell;
	//			update account_investment set number_of_shares = '90' where account_num = 'A000006' and invest_symbol = 'VC' and time = TO_TIMESTAMP('2014-04-07 22:05:00.0', 'YYYY-MM-DD HH24:MI:SS.FF');
	//			insert into transaction values ('T000049', 'A000006', '84.5', TO_DATE('2014-04-10','YYYY-MM-DD'), '7');
	//			insert into invest_transaction values ('T000049', 'VC', '10')
				amount = crtPrice * toSell;
				
				gainOrLoss = (crtPrice - prevPrice) * toSell; // check the gain or loss for the tax statement
				if (Utility.isLongTerm(targetTime, todayTime)) {
					shortOrLong = 1; // long term
				} else {
					shortOrLong = 0; // short term
				}
						
			    String newTransID = Utility.getNewID(control.getLatestTransID());
			    
				String query0 = "update account_investment set number_of_shares = '" + ownNumber + "' where account_num = '" + accountID + "' and invest_symbol = '" +
									investSymbol + "' and time = TO_TIMESTAMP('" + targetTime + "', 'YYYY-MM-DD HH24:MI:SS.FF')";
				String query1 = "insert into transaction values('" + newTransID + "', '" + accountID + 
									"', '" + amount + "', TO_DATE('" + sqlDate + "','YYYY-MM-DD'), '7')";
				String query2 = "insert into invest_transaction values('" + newTransID + "', '" + investSymbol + "', '" + toSell+ "', '" + 
									gainOrLoss + "', '" + shortOrLong + "')";
	
//				System.out.println(query0);
//				System.out.println(query1);
//				System.out.println(query2);
					
				int result0, result1, result2;
				result0 = s.executeUpdate(query0);
				result1 = s.executeUpdate(query1);
				result2 = s.executeUpdate(query2);
					
				if (!(result0 > 0 && result1 > 0 && result2 > 0)) {
					flag = false;
					break;
				}			
			}// end while
			
			s.close();
			con.commit();
			con.setAutoCommit(true);
		} catch (SQLException e) {
			try {
				con.rollback();
				con.setAutoCommit(true);
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			flag = false;
		}
		
		return flag;
	}