geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hogst...@apache.org
Subject svn commit: r558518 [2/2] - /geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java
Date Sun, 22 Jul 2007 18:16:22 GMT

Modified: geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java?view=diff&rev=558518&r1=558517&r2=558518
==============================================================================
--- geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java (original)
+++ geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java Sun Jul 22 11:16:21 2007
@@ -39,36 +39,43 @@
 import org.apache.geronimo.samples.daytrader.*;
 
 /**
-  * TradeDirect uses direct JDBC and JMS access to a <code>javax.sql.DataSource</code> to implement the business methods 
-  * of the Trade online broker application. These business methods represent the features and operations that 
-  * can be performed by customers of the brokerage such as login, logout, get a stock quote, buy or sell a stock, etc.
-  * and are specified in the {@link org.apache.geronimo.samples.daytrader.TradeServices} interface
-  *
-  * Note: In order for this class to be thread-safe, a new TradeJDBC must be created
-  * for each call to a method from the TradeInterface interface.  Otherwise, pooled
-  * connections may not be released.
-  *
-  * @see org.apache.geronimo.samples.daytrader.TradeServices
-  * @see org.apache.geronimo.samples.daytrader.ejb.Trade
-  *
-  */
+ * TradeDirect uses direct JDBC and JMS access to a
+ * <code>javax.sql.DataSource</code> to implement the business methods of the
+ * Trade online broker application. These business methods represent the
+ * features and operations that can be performed by customers of the brokerage
+ * such as login, logout, get a stock quote, buy or sell a stock, etc. and are
+ * specified in the {@link org.apache.geronimo.samples.daytrader.TradeServices}
+ * interface
+ * 
+ * Note: In order for this class to be thread-safe, a new TradeJDBC must be
+ * created for each call to a method from the TradeInterface interface.
+ * Otherwise, pooled connections may not be released.
+ * 
+ * @see org.apache.geronimo.samples.daytrader.TradeServices
+ * @see org.apache.geronimo.samples.daytrader.ejb.Trade
+ * 
+ */
 
 public class TradeDirect implements TradeServices
-			
+
 {
-	
+
 	private static String dsName = TradeConfig.DATASOURCE;
+
 	private static DataSource datasource = null;
+
 	private static BigDecimal ZERO = new BigDecimal(0.0);
+
 	private boolean inGlobalTxn = false;
-	private boolean inSession = false;
 
+	private boolean inSession = false;
 
 	/**
-	 * Zero arg constructor for TradeDirect
-	 */
+     * Zero arg constructor for TradeDirect
+     */
 	public TradeDirect() {
-	    if (initialized==false) init();
+		if (initialized == false)
+			init();
 	}
 
 	public TradeDirect(boolean inSession) {
@@ -79,531 +86,531 @@
 	}
 
 	/**
-	 * @see TradeServices#getMarketSummary()
-	 */
+     * @see TradeServices#getMarketSummary()
+     */
 	public MarketSummaryDataBean getMarketSummary() throws Exception {
-		
+
 		MarketSummaryDataBean marketSummaryData = null;
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getMarketSummary - inSession(" + this.inSession + ")");
-			
+		Connection conn = null;
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:getMarketSummary - inSession("
+						+ this.inSession + ")");
+
 			conn = getConn();
-            PreparedStatement stmt = getStatement(conn, getTSIAQuotesOrderByChangeSQL, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
-            
-		    ArrayList topGainersData = new ArrayList(5);
-		    ArrayList topLosersData = new ArrayList(5);		    
+			PreparedStatement stmt = getStatement(conn,
+					getTSIAQuotesOrderByChangeSQL,
+					ResultSet.TYPE_SCROLL_INSENSITIVE,
+					ResultSet.CONCUR_READ_ONLY);
+
+			ArrayList topGainersData = new ArrayList(5);
+			ArrayList topLosersData = new ArrayList(5);
 
 			ResultSet rs = stmt.executeQuery();
-			
-			int count = 0; 
-			while (rs.next() && (count++ < 5) )
-			{
+
+			int count = 0;
+			while (rs.next() && (count++ < 5)) {
 				QuoteDataBean quoteData = getQuoteDataFromResultSet(rs);
 				topLosersData.add(quoteData);
 			}
-			
-			
+
 			stmt.close();
-            stmt = getStatement(conn, "select * from quoteejb q where q.symbol like 's:1__' order by q.change1 DESC", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );			
+			stmt = getStatement(
+					conn,
+					"select * from quoteejb q where q.symbol like 's:1__' order by q.change1 DESC",
+					ResultSet.TYPE_SCROLL_INSENSITIVE,
+					ResultSet.CONCUR_READ_ONLY);
 			rs = stmt.executeQuery();
 
-			count = 0; 
-			while (rs.next() && (count++ < 5) )
-			{
+			count = 0;
+			while (rs.next() && (count++ < 5)) {
 				QuoteDataBean quoteData = getQuoteDataFromResultSet(rs);
 				topGainersData.add(quoteData);
 			}
-			         
-		
+
 			/*
-			rs.last();
-			count = 0;
-			while (rs.previous() && (count++ < 5) )
-			{
-				QuoteDataBean quoteData = getQuoteDataFromResultSet(rs);
-				topGainersData.add(quoteData);
-			}*/
-			
-			stmt.close();
-			
-            BigDecimal TSIA = ZERO;
-            BigDecimal openTSIA = ZERO;
-            double volume=0.0;
-
-            if ( (topGainersData.size() > 0) || (topLosersData.size() > 0)){ 
-			
-			stmt = getStatement(conn, getTSIASQL);
-			rs = stmt.executeQuery();
+             * rs.last(); count = 0; while (rs.previous() && (count++ < 5) ) {
+             * QuoteDataBean quoteData = getQuoteDataFromResultSet(rs);
+             * topGainersData.add(quoteData); }
+             */
 
-			if (!rs.next() )  
-				Log.error("TradeDirect:getMarketSummary -- error w/ getTSIASQL -- no results");
-			else 
-				TSIA = rs.getBigDecimal("TSIA");
 			stmt.close();
 
-			
-			stmt = getStatement(conn, getOpenTSIASQL);
-			rs = stmt.executeQuery();
+			BigDecimal TSIA = ZERO;
+			BigDecimal openTSIA = ZERO;
+			double volume = 0.0;
+
+			if ((topGainersData.size() > 0) || (topLosersData.size() > 0)) {
+
+				stmt = getStatement(conn, getTSIASQL);
+				rs = stmt.executeQuery();
+
+				if (!rs.next())
+					Log
+							.error("TradeDirect:getMarketSummary -- error w/ getTSIASQL -- no results");
+				else
+					TSIA = rs.getBigDecimal("TSIA");
+				stmt.close();
 
-			if (!rs.next() )  
-				Log.error("TradeDirect:getMarketSummary -- error w/ getOpenTSIASQL -- no results");
-			else 
-				openTSIA = rs.getBigDecimal("openTSIA");
-			stmt.close();
+				stmt = getStatement(conn, getOpenTSIASQL);
+				rs = stmt.executeQuery();
 
-			stmt = getStatement(conn, getTSIATotalVolumeSQL);
-			rs = stmt.executeQuery();
+				if (!rs.next())
+					Log
+							.error("TradeDirect:getMarketSummary -- error w/ getOpenTSIASQL -- no results");
+				else
+					openTSIA = rs.getBigDecimal("openTSIA");
+				stmt.close();
 
-			if (!rs.next() ) 
-				Log.error("TradeDirect:getMarketSummary -- error w/ getTSIATotalVolumeSQL -- no results");
-			else 
-				volume = rs.getDouble("totalVolume");
-			stmt.close();
-            }
+				stmt = getStatement(conn, getTSIATotalVolumeSQL);
+				rs = stmt.executeQuery();
+
+				if (!rs.next())
+					Log
+							.error("TradeDirect:getMarketSummary -- error w/ getTSIATotalVolumeSQL -- no results");
+				else
+					volume = rs.getDouble("totalVolume");
+				stmt.close();
+			}
 			commit(conn);
-				
-			marketSummaryData = new MarketSummaryDataBean(TSIA, openTSIA, volume, topGainersData, topLosersData);
+
+			marketSummaryData = new MarketSummaryDataBean(TSIA, openTSIA,
+					volume, topGainersData, topLosersData);
 
 		}
 
-		catch (Exception e)
-		{
+		catch (Exception e) {
 			Log.error("TradeDirect:login -- error logging in user", e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		return marketSummaryData;		
+		return marketSummaryData;
 
 	}
 
 	/**
-	 * @see TradeServices#buy(String, String, double)
-	 */
-	public OrderDataBean buy(String userID, String symbol, double quantity, int orderProcessingMode)
-		throws Exception {
+     * @see TradeServices#buy(String, String, double)
+     */
+	public OrderDataBean buy(String userID, String symbol, double quantity,
+			int orderProcessingMode) throws Exception {
 
-		Connection conn=null;
+		Connection conn = null;
 		OrderDataBean orderData = null;
 		UserTransaction txn = null;
-		
+
 		/*
-		 * total = (quantity * purchasePrice) + orderFee
-		 */
+         * total = (quantity * purchasePrice) + orderFee
+         */
 		BigDecimal total;
-		
-	
-		try
-		{
-			if (Log.doTrace()) 
-				Log.trace("TradeDirect:buy - inSession(" + this.inSession + ")", userID, symbol, new Double(quantity));
-			
-			if ( !inSession && orderProcessingMode == TradeConfig.ASYNCH_2PHASE )
-			{
-				if ( Log.doTrace() )
-					Log.trace("TradeDirect:buy create/begin global transaction");		
-				//FUTURE the UserTransaction be looked up once
-				txn = (javax.transaction.UserTransaction) context.lookup("java:comp/UserTransaction");
+
+		try {
+			if (Log.doTrace())
+				Log.trace(
+						"TradeDirect:buy - inSession(" + this.inSession + ")",
+						userID, symbol, new Double(quantity));
+
+			if (!inSession && orderProcessingMode == TradeConfig.ASYNCH_2PHASE) {
+				if (Log.doTrace())
+					Log
+							.trace("TradeDirect:buy create/begin global transaction");
+				// FUTURE the UserTransaction be looked up once
+				txn = (javax.transaction.UserTransaction) context
+						.lookup("java:comp/UserTransaction");
 				txn.begin();
 				setInGlobalTxn(true);
 			}
-		
+
 			conn = getConn();
-			
+
 			AccountDataBean accountData = getAccountData(conn, userID);
 			QuoteDataBean quoteData = getQuoteData(conn, symbol);
-			HoldingDataBean holdingData = null; // the buy operation will create the holding
+			HoldingDataBean holdingData = null; // the buy operation will create
+                                                // the holding
 
-			orderData = createOrder(conn, accountData, quoteData, holdingData, "buy", quantity);
+			orderData = createOrder(conn, accountData, quoteData, holdingData,
+					"buy", quantity);
 
-			//Update -- account should be credited during completeOrder
+			// Update -- account should be credited during completeOrder
 			BigDecimal price = quoteData.getPrice();
 			BigDecimal orderFee = orderData.getOrderFee();
-			total   = (new BigDecimal(quantity).multiply(price)).add(orderFee);
+			total = (new BigDecimal(quantity).multiply(price)).add(orderFee);
 			// subtract total from account balance
 			creditAccountBalance(conn, accountData, total.negate());
 
 			try {
-				if (orderProcessingMode == TradeConfig.SYNCH) 
+				if (orderProcessingMode == TradeConfig.SYNCH)
 					completeOrder(conn, orderData.getOrderID());
 				else if (orderProcessingMode == TradeConfig.ASYNCH_2PHASE)
-					queueOrder(orderData.getOrderID(), true);	// 2-phase commit
-			}
-			catch (JMSException je)
-			{
-				Log.error("TradeBean:buy("+userID+","+symbol+","+quantity+") --> failed to queueOrder", je);
+					queueOrder(orderData.getOrderID(), true); // 2-phase
+                                                                // commit
+			} catch (JMSException je) {
+				Log.error("TradeBean:buy(" + userID + "," + symbol + ","
+						+ quantity + ") --> failed to queueOrder", je);
 				/* On exception - cancel the order */
 
-				cancelOrder(conn, orderData.getOrderID());	
+				cancelOrder(conn, orderData.getOrderID());
 			}
 
-                        orderData = getOrderData(conn, orderData.getOrderID().intValue());
-			
+			orderData = getOrderData(conn, orderData.getOrderID().intValue());
+
 			if (txn != null) {
-				if ( Log.doTrace() )
-					Log.trace("TradeDirect:buy committing global transaction");		
+				if (Log.doTrace())
+					Log.trace("TradeDirect:buy committing global transaction");
 				txn.commit();
 				setInGlobalTxn(false);
-			}
-			else
+			} else
 				commit(conn);
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			Log.error("TradeDirect:buy error - rolling back", e);
-			if ( getInGlobalTxn() )
+			if (getInGlobalTxn())
 				txn.rollback();
 			else
 				rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
 
-		return orderData;		
+		return orderData;
 	}
 
 	/**
-	 * @see TradeServices#sell(String, Integer)
-	 */
-	public OrderDataBean sell(String userID, Integer holdingID, int orderProcessingMode)
-		throws Exception {
-		Connection conn=null;
+     * @see TradeServices#sell(String, Integer)
+     */
+	public OrderDataBean sell(String userID, Integer holdingID,
+			int orderProcessingMode) throws Exception {
+		Connection conn = null;
 		OrderDataBean orderData = null;
 		UserTransaction txn = null;
-		
+
 		/*
-		 * total = (quantity * purchasePrice) + orderFee
-		 */
+         * total = (quantity * purchasePrice) + orderFee
+         */
 		BigDecimal total;
-		
-		try
-		{
-			if (Log.doTrace()) 
-				Log.trace("TradeDirect:sell - inSession(" + this.inSession + ")", userID, holdingID);
 
-			if ( !inSession && orderProcessingMode == TradeConfig.ASYNCH_2PHASE )
-			{
-				if ( Log.doTrace() )
-					Log.trace("TradeDirect:sell create/begin global transaction");		
-				//FUTURE the UserTransaction be looked up once
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:sell - inSession(" + this.inSession
+						+ ")", userID, holdingID);
+
+			if (!inSession && orderProcessingMode == TradeConfig.ASYNCH_2PHASE) {
+				if (Log.doTrace())
+					Log
+							.trace("TradeDirect:sell create/begin global transaction");
+				// FUTURE the UserTransaction be looked up once
 
-				txn = (javax.transaction.UserTransaction) context.lookup("java:comp/UserTransaction");
+				txn = (javax.transaction.UserTransaction) context
+						.lookup("java:comp/UserTransaction");
 				txn.begin();
 				setInGlobalTxn(true);
 			}
-			
+
 			conn = getConn();
-			
+
 			AccountDataBean accountData = getAccountData(conn, userID);
-			HoldingDataBean holdingData = getHoldingData(conn, holdingID.intValue() );
+			HoldingDataBean holdingData = getHoldingData(conn, holdingID
+					.intValue());
 			QuoteDataBean quoteData = null;
-			if ( holdingData != null) quoteData = getQuoteData(conn, holdingData.getQuoteID());
-			
-			if ( (accountData==null) || (holdingData==null) || (quoteData==null) )
-			{
-				String error = "TradeDirect:sell -- error selling stock -- unable to find:  \n\taccount=" +accountData + "\n\tholding=" + holdingData + "\n\tquote="+quoteData + "\nfor user: " + userID + " and holdingID: " + holdingID;
+			if (holdingData != null)
+				quoteData = getQuoteData(conn, holdingData.getQuoteID());
+
+			if ((accountData == null) || (holdingData == null)
+					|| (quoteData == null)) {
+				String error = "TradeDirect:sell -- error selling stock -- unable to find:  \n\taccount="
+						+ accountData
+						+ "\n\tholding="
+						+ holdingData
+						+ "\n\tquote="
+						+ quoteData
+						+ "\nfor user: "
+						+ userID
+						+ " and holdingID: " + holdingID;
 				Log.error(error);
-				if ( getInGlobalTxn() )
+				if (getInGlobalTxn())
 					txn.rollback();
 				else
-					rollBack(conn, new Exception(error));							
+					rollBack(conn, new Exception(error));
 				return orderData;
 			}
 
-			double		 quantity = holdingData.getQuantity();
+			double quantity = holdingData.getQuantity();
+
+			orderData = createOrder(conn, accountData, quoteData, holdingData,
+					"sell", quantity);
 
-			orderData = createOrder(conn, accountData, quoteData, holdingData, "sell", quantity);
-			
-			// Set the holdingSymbol purchaseDate to selling to signify the sell is "inflight"
-			updateHoldingStatus(conn, holdingData.getHoldingID(), holdingData.getQuoteID());		
+			// Set the holdingSymbol purchaseDate to selling to signify the sell
+            // is "inflight"
+			updateHoldingStatus(conn, holdingData.getHoldingID(), holdingData
+					.getQuoteID());
 
-			//UPDATE -- account should be credited during completeOrder
+			// UPDATE -- account should be credited during completeOrder
 			BigDecimal price = quoteData.getPrice();
 			BigDecimal orderFee = orderData.getOrderFee();
-			total   = (new BigDecimal(quantity).multiply(price)).subtract(orderFee);
+			total = (new BigDecimal(quantity).multiply(price))
+					.subtract(orderFee);
 			creditAccountBalance(conn, accountData, total);
 
 			try {
-				if (orderProcessingMode == TradeConfig.SYNCH) 
+				if (orderProcessingMode == TradeConfig.SYNCH)
 					completeOrder(conn, orderData.getOrderID());
 				else if (orderProcessingMode == TradeConfig.ASYNCH_2PHASE)
-					queueOrder(orderData.getOrderID(), true);      // 2-phase commit
-			}
-			catch (JMSException je)
-			{
-				Log.error("TradeBean:sell("+userID+","+holdingID+") --> failed to queueOrder", je);
+					queueOrder(orderData.getOrderID(), true); // 2-phase
+                                                                // commit
+			} catch (JMSException je) {
+				Log.error("TradeBean:sell(" + userID + "," + holdingID
+						+ ") --> failed to queueOrder", je);
 				/* On exception - cancel the order */
 
-				cancelOrder(conn, orderData.getOrderID());	
+				cancelOrder(conn, orderData.getOrderID());
 			}
 
-                        orderData = getOrderData(conn, orderData.getOrderID().intValue());
+			orderData = getOrderData(conn, orderData.getOrderID().intValue());
 
 			if (txn != null) {
-				if ( Log.doTrace() )
-					Log.trace("TradeDirect:sell committing global transaction");		
+				if (Log.doTrace())
+					Log.trace("TradeDirect:sell committing global transaction");
 				txn.commit();
 				setInGlobalTxn(false);
-			}
-			else	
-				commit(conn);			
-		}
-		catch (Exception e)
-		{
+			} else
+				commit(conn);
+		} catch (Exception e) {
 			Log.error("TradeDirect:sell error", e);
-			if ( getInGlobalTxn() )
+			if (getInGlobalTxn())
 				txn.rollback();
 			else
 				rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		
-		return orderData;		
+
+		return orderData;
 	}
 
 	/**
-	 * @see TradeServices#queueOrder(Integer)
-	 */
-	public void queueOrder(Integer orderID, boolean twoPhase) throws Exception 
-	{
-		if (Log.doTrace() ) Log.trace("TradeDirect:queueOrder - inSession(" + this.inSession + ")", orderID);
+     * @see TradeServices#queueOrder(Integer)
+     */
+	public void queueOrder(Integer orderID, boolean twoPhase) throws Exception {
+		if (Log.doTrace())
+			Log.trace("TradeDirect:queueOrder - inSession(" + this.inSession
+					+ ")", orderID);
 
-		javax.jms.Connection conn = null;	
+		javax.jms.Connection conn = null;
 		Session sess = null;
-	
-		try 
-		{	
-			conn = qConnFactory.createConnection();		
+
+		try {
+			conn = qConnFactory.createConnection();
 			sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
 			MessageProducer producer = sess.createProducer(queue);
 
-			TextMessage   message = sess.createTextMessage();
+			TextMessage message = sess.createTextMessage();
 
-			String command= "neworder";
+			String command = "neworder";
 			message.setStringProperty("command", command);
 			message.setIntProperty("orderID", orderID.intValue());
 			message.setBooleanProperty("twoPhase", twoPhase);
 			message.setBooleanProperty("direct", true);
-			message.setLongProperty("publishTime", System.currentTimeMillis());					
-			message.setText("neworder: orderID="+orderID + " runtimeMode=Direct twoPhase="+twoPhase);
+			message.setLongProperty("publishTime", System.currentTimeMillis());
+			message.setText("neworder: orderID=" + orderID
+					+ " runtimeMode=Direct twoPhase=" + twoPhase);
 
-			if (Log.doTrace()) 
-				Log.trace("TradeDirectBean:queueOrder Sending message: " + message.getText());
+			if (Log.doTrace())
+				Log.trace("TradeDirectBean:queueOrder Sending message: "
+						+ message.getText());
 			producer.send(message);
 			sess.close();
 		}
-		
-		catch (Exception e)
-		{
+
+		catch (Exception e) {
 			throw e; // pass the exception back
 		}
-		
-		finally
-		{
-			if (sess != null)	
+
+		finally {
+			if (sess != null)
 				sess.close();
 			if (conn != null)
 				conn.close();
 		}
 	}
 
-
 	/**
-	 * @see TradeServices#completeOrder(Integer)
-	 */
-	public OrderDataBean completeOrder(Integer orderID, boolean twoPhase) throws Exception 
-	{
+     * @see TradeServices#completeOrder(Integer)
+     */
+	public OrderDataBean completeOrder(Integer orderID, boolean twoPhase)
+			throws Exception {
 		OrderDataBean orderData = null;
-		Connection conn=null;
-		
-		try  //twoPhase
+		Connection conn = null;
+
+		try // twoPhase
 		{
 
-			if (Log.doTrace()) Log.trace("TradeDirect:completeOrder - inSession(" + this.inSession + ")", orderID);
+			if (Log.doTrace())
+				Log.trace("TradeDirect:completeOrder - inSession("
+						+ this.inSession + ")", orderID);
 			setInGlobalTxn(!inSession && twoPhase);
 			conn = getConn();
 			orderData = completeOrder(conn, orderID);
 			commit(conn);
 
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			Log.error("TradeDirect:completeOrder -- error completing order", e);
 			rollBack(conn, e);
 			cancelOrder(orderID, twoPhase);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-			
-		return orderData;         	
-		
-	}
-	
-
-	private OrderDataBean completeOrder(Connection conn, Integer orderID) 
-			throws Exception
-	{
-			
+
+		return orderData;
+
+	}
+
+	private OrderDataBean completeOrder(Connection conn, Integer orderID)
+			throws Exception {
+
 		OrderDataBean orderData = null;
-		if (Log.doTrace()) Log.trace("TradeDirect:completeOrderInternal - inSession(" + this.inSession + ")", orderID);
+		if (Log.doTrace())
+			Log.trace("TradeDirect:completeOrderInternal - inSession("
+					+ this.inSession + ")", orderID);
 
 		PreparedStatement stmt = getStatement(conn, getOrderSQL);
-        stmt.setInt(1, orderID.intValue());
+		stmt.setInt(1, orderID.intValue());
 
 		ResultSet rs = stmt.executeQuery();
 
-		if ( !rs.next() )
-		{
-			Log.error("TradeDirect:completeOrder -- unable to find order: " + orderID);
+		if (!rs.next()) {
+			Log.error("TradeDirect:completeOrder -- unable to find order: "
+					+ orderID);
 			stmt.close();
 			return orderData;
 		}
 		orderData = getOrderDataFromResultSet(rs);
-		
+
 		String orderType = orderData.getOrderType();
 		String orderStatus = orderData.getOrderStatus();
-		
-		//if (order.isCompleted())
-    	if ( (orderStatus.compareToIgnoreCase("completed") == 0) ||
-	         (orderStatus.compareToIgnoreCase("alertcompleted") == 0)    ||
-	         (orderStatus.compareToIgnoreCase("cancelled") == 0) ) 	         
-			throw new Exception("TradeDirect:completeOrder -- attempt to complete Order that is already completed");
-	
-		int        accountID = rs.getInt("account_accountID");
-		String       quoteID = rs.getString("quote_symbol");
-		int        holdingID = rs.getInt("holding_holdingID");
-		
-		BigDecimal     price = orderData.getPrice();
-		double	    quantity = orderData.getQuantity();
-		BigDecimal  orderFee = orderData.getOrderFee();
-
-		//get the data for the account and quote 
-		//the holding will be created for a buy or extracted for a sell
-
-
-		/* Use the AccountID and Quote Symbol from the Order
-			AccountDataBean accountData = getAccountData(accountID, conn);
-			QuoteDataBean     quoteData = getQuoteData(conn, quoteID);
-		 */
-		String 				 userID = getAccountProfileData(conn, new Integer(accountID)).getUserID();
+
+		// if (order.isCompleted())
+		if ((orderStatus.compareToIgnoreCase("completed") == 0)
+				|| (orderStatus.compareToIgnoreCase("alertcompleted") == 0)
+				|| (orderStatus.compareToIgnoreCase("cancelled") == 0))
+			throw new Exception(
+					"TradeDirect:completeOrder -- attempt to complete Order that is already completed");
+
+		int accountID = rs.getInt("account_accountID");
+		String quoteID = rs.getString("quote_symbol");
+		int holdingID = rs.getInt("holding_holdingID");
+
+		BigDecimal price = orderData.getPrice();
+		double quantity = orderData.getQuantity();
+		BigDecimal orderFee = orderData.getOrderFee();
+
+		// get the data for the account and quote
+		// the holding will be created for a buy or extracted for a sell
+
+		/*
+         * Use the AccountID and Quote Symbol from the Order AccountDataBean
+         * accountData = getAccountData(accountID, conn); QuoteDataBean
+         * quoteData = getQuoteData(conn, quoteID);
+         */
+		String userID = getAccountProfileData(conn, new Integer(accountID))
+				.getUserID();
 
 		HoldingDataBean holdingData = null;
-		
-		if (Log.doTrace()) Log.trace(
-				"TradeDirect:completeOrder--> Completing Order " + orderData.getOrderID()
-				 + "\n\t Order info: "   +   orderData
-				 + "\n\t Account info: " + accountID
-				 + "\n\t Quote info: "   +   quoteID);
-
-		//if (order.isBuy())
-	  	if ( orderType.compareToIgnoreCase("buy") == 0 )
-	  	{ 
-			/* Complete a Buy operation
-			 *	- create a new Holding for the Account
-			 *	- deduct the Order cost from the Account balance
-			 */
-	
-			holdingData = createHolding(conn, accountID, quoteID, quantity, price);
-			updateOrderHolding(conn, orderID.intValue(), holdingData.getHoldingID().intValue());
-		}
-		
-		//if (order.isSell()) {
-	  	if ( orderType.compareToIgnoreCase("sell") == 0 ) 
-	  	{	
-			/* Complete a Sell operation
-			 *	- remove the Holding from the Account
-			 *	- deposit the Order proceeds to the Account balance
-			 */	
+
+		if (Log.doTrace())
+			Log.trace("TradeDirect:completeOrder--> Completing Order "
+					+ orderData.getOrderID() + "\n\t Order info: " + orderData
+					+ "\n\t Account info: " + accountID + "\n\t Quote info: "
+					+ quoteID);
+
+		// if (order.isBuy())
+		if (orderType.compareToIgnoreCase("buy") == 0) {
+			/*
+             * Complete a Buy operation - create a new Holding for the Account -
+             * deduct the Order cost from the Account balance
+             */
+
+			holdingData = createHolding(conn, accountID, quoteID, quantity,
+					price);
+			updateOrderHolding(conn, orderID.intValue(), holdingData
+					.getHoldingID().intValue());
+		}
+
+		// if (order.isSell()) {
+		if (orderType.compareToIgnoreCase("sell") == 0) {
+			/*
+             * Complete a Sell operation - remove the Holding from the Account -
+             * deposit the Order proceeds to the Account balance
+             */
 			holdingData = getHoldingData(conn, holdingID);
-			if ( holdingData == null )
-				Log.debug("TradeDirect:completeOrder:sell -- user: " + userID + " already sold holding: " + holdingID);			
+			if (holdingData == null)
+				Log.debug("TradeDirect:completeOrder:sell -- user: " + userID
+						+ " already sold holding: " + holdingID);
 			else
-				removeHolding(conn, holdingID, orderID.intValue());		
+				removeHolding(conn, holdingID, orderID.intValue());
 
 		}
 
 		updateOrderStatus(conn, orderData.getOrderID(), "closed");
-		
-		if (Log.doTrace()) Log.trace(
-			"TradeDirect:completeOrder--> Completed Order " + orderData.getOrderID()
-				 + "\n\t Order info: "   +   orderData
-				 + "\n\t Account info: " + accountID
-				 + "\n\t Quote info: "   +   quoteID
-				 + "\n\t Holding info: " + holdingData);
+
+		if (Log.doTrace())
+			Log.trace("TradeDirect:completeOrder--> Completed Order "
+					+ orderData.getOrderID() + "\n\t Order info: " + orderData
+					+ "\n\t Account info: " + accountID + "\n\t Quote info: "
+					+ quoteID + "\n\t Holding info: " + holdingData);
 
 		stmt.close();
 
 		commit(conn);
 
-		//signify this order for user userID is complete		
-		TradeAction tradeAction = new TradeAction(this);		
+		// signify this order for user userID is complete
+		TradeAction tradeAction = new TradeAction(this);
 		tradeAction.orderCompleted(userID, orderID);
 
 		return orderData;
 	}
-	
+
 	/**
-	 * @see TradeServices#cancelOrder(Integer, boolean)
-	 */
-	public void cancelOrder(Integer orderID, boolean twoPhase) 
-	throws Exception 
-	{
+     * @see TradeServices#cancelOrder(Integer, boolean)
+     */
+	public void cancelOrder(Integer orderID, boolean twoPhase) throws Exception {
 		OrderDataBean orderData = null;
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:cancelOrder - inSession(" + this.inSession + ")", orderID);
+		Connection conn = null;
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:cancelOrder - inSession("
+						+ this.inSession + ")", orderID);
 			setInGlobalTxn(!inSession && twoPhase);
 			conn = getConn();
 			cancelOrder(conn, orderID);
 			commit(conn);
 
-		}
-		catch (Exception e)
-		{
-			Log.error("TradeDirect:cancelOrder -- error cancelling order: "+orderID, e);
+		} catch (Exception e) {
+			Log.error("TradeDirect:cancelOrder -- error cancelling order: "
+					+ orderID, e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
-		}		
+		}
 	}
-	
-	private void cancelOrder(Connection conn, Integer orderID) 
-	throws Exception 
-	{
+
+	private void cancelOrder(Connection conn, Integer orderID) throws Exception {
 		updateOrderStatus(conn, orderID, "cancelled");
 	}
-	
 
-	public void orderCompleted(String userID, Integer orderID) 
-	throws Exception
-	{
-		throw new UnsupportedOperationException("TradeDirect:orderCompleted method not supported");
-	}
-	
-
-	private HoldingDataBean createHolding(Connection conn, int accountID, String symbol, double quantity, BigDecimal purchasePrice) 
-		throws Exception 
-	{
+	public void orderCompleted(String userID, Integer orderID) throws Exception {
+		throw new UnsupportedOperationException(
+				"TradeDirect:orderCompleted method not supported");
+	}
+
+	private HoldingDataBean createHolding(Connection conn, int accountID,
+			String symbol, double quantity, BigDecimal purchasePrice)
+			throws Exception {
 		HoldingDataBean holdingData = null;
 
 		Timestamp purchaseDate = new Timestamp(System.currentTimeMillis());
 		PreparedStatement stmt = getStatement(conn, createHoldingSQL);
-	
-		Integer holdingID = KeySequenceDirect.getNextID(conn, "holding", inSession, getInGlobalTxn());
+
+		Integer holdingID = KeySequenceDirect.getNextID(conn, "holding",
+				inSession, getInGlobalTxn());
 		stmt.setInt(1, holdingID.intValue());
 		stmt.setTimestamp(2, purchaseDate);
 		stmt.setBigDecimal(3, purchasePrice);
@@ -613,257 +620,247 @@
 		int rowCount = stmt.executeUpdate();
 
 		stmt.close();
-				
+
 		return getHoldingData(conn, holdingID.intValue());
 	}
-	private void removeHolding(Connection conn, int holdingID, int orderID) 
-		throws Exception 
-	{
+
+	private void removeHolding(Connection conn, int holdingID, int orderID)
+			throws Exception {
 		PreparedStatement stmt = getStatement(conn, removeHoldingSQL);
-	
+
 		stmt.setInt(1, holdingID);
 		int rowCount = stmt.executeUpdate();
-		stmt.close();	
+		stmt.close();
 
 		// set the HoldingID to NULL for the purchase and sell order now that
-		// the holding as been removed		
+		// the holding as been removed
 		stmt = getStatement(conn, removeHoldingFromOrderSQL);
-	
+
 		stmt.setInt(1, holdingID);
 		rowCount = stmt.executeUpdate();
-		stmt.close();	
-		
+		stmt.close();
+
 	}
-	
-	private OrderDataBean createOrder(Connection conn, AccountDataBean accountData, QuoteDataBean quoteData, HoldingDataBean holdingData, String orderType, double quantity) 
-		throws Exception 
-	{
+
+	private OrderDataBean createOrder(Connection conn,
+			AccountDataBean accountData, QuoteDataBean quoteData,
+			HoldingDataBean holdingData, String orderType, double quantity)
+			throws Exception {
 		OrderDataBean orderData = null;
 
 		Timestamp currentDate = new Timestamp(System.currentTimeMillis());
-				
+
 		PreparedStatement stmt = getStatement(conn, createOrderSQL);
-	
 
-		Integer orderID = KeySequenceDirect.getNextID(conn, "order", inSession, getInGlobalTxn());
+		Integer orderID = KeySequenceDirect.getNextID(conn, "order", inSession,
+				getInGlobalTxn());
 		stmt.setInt(1, orderID.intValue());
 		stmt.setString(2, orderType);
 		stmt.setString(3, "open");
 		stmt.setTimestamp(4, currentDate);
 		stmt.setDouble(5, quantity);
-		stmt.setBigDecimal(6, quoteData.getPrice().setScale(FinancialUtils.SCALE, FinancialUtils.ROUND));
+		stmt.setBigDecimal(6, quoteData.getPrice().setScale(
+				FinancialUtils.SCALE, FinancialUtils.ROUND));
 		stmt.setBigDecimal(7, TradeConfig.getOrderFee(orderType));
 		stmt.setInt(8, accountData.getAccountID().intValue());
-		if (holdingData == null ) stmt.setNull(9, java.sql.Types.INTEGER);
-		else stmt.setInt(9, holdingData.getHoldingID().intValue());
-		stmt.setString(10, quoteData.getSymbol());		
+		if (holdingData == null)
+			stmt.setNull(9, java.sql.Types.INTEGER);
+		else
+			stmt.setInt(9, holdingData.getHoldingID().intValue());
+		stmt.setString(10, quoteData.getSymbol());
 		int rowCount = stmt.executeUpdate();
 
 		stmt.close();
-				
+
 		return getOrderData(conn, orderID.intValue());
 	}
-	
 
 	/**
-	 * @see TradeServices#getOrders(String)
-	 */
+     * @see TradeServices#getOrders(String)
+     */
 	public Collection getOrders(String userID) throws Exception {
 		Collection orderDataBeans = new ArrayList();
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getOrders - inSession(" + this.inSession + ")", userID);
-			
+		Connection conn = null;
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:getOrders - inSession(" + this.inSession
+						+ ")", userID);
+
 			conn = getConn();
-            PreparedStatement stmt = getStatement(conn, getOrdersByUserSQL);
-            stmt.setString(1, userID);
+			PreparedStatement stmt = getStatement(conn, getOrdersByUserSQL);
+			stmt.setString(1, userID);
 
 			ResultSet rs = stmt.executeQuery();
 
-			//TODO: return top 5 orders for now -- next version will add a getAllOrders method
-			//      also need to get orders sorted by order id descending			
-			int i=0;
-			while ( (rs.next()) && (i++ < 5) )
-			{			
+			// TODO: return top 5 orders for now -- next version will add a
+            // getAllOrders method
+			// also need to get orders sorted by order id descending
+			int i = 0;
+			while ((rs.next()) && (i++ < 5)) {
 				OrderDataBean orderData = getOrderDataFromResultSet(rs);
 				orderDataBeans.add(orderData);
 			}
 
 			stmt.close();
 			commit(conn);
-				
-		}
-		catch (Exception e)
-		{
+
+		} catch (Exception e) {
 			Log.error("TradeDirect:getOrders -- error getting user orders", e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
 		return orderDataBeans;
 	}
 
 	/**
-	 * @see TradeServices#getClosedOrders(String)
-	 */
+     * @see TradeServices#getClosedOrders(String)
+     */
 	public Collection getClosedOrders(String userID) throws Exception {
 		Collection orderDataBeans = new ArrayList();
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getClosedOrders - inSession(" + this.inSession + ")", userID);
-			
+		Connection conn = null;
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:getClosedOrders - inSession("
+						+ this.inSession + ")", userID);
+
 			conn = getConn();
-            PreparedStatement stmt = getStatement(conn, getClosedOrdersSQL);
-            stmt.setString(1, userID);
+			PreparedStatement stmt = getStatement(conn, getClosedOrdersSQL);
+			stmt.setString(1, userID);
 
 			ResultSet rs = stmt.executeQuery();
 
-			while ( rs.next() )
-			{			
-				OrderDataBean orderData = getOrderDataFromResultSet(rs);	
+			while (rs.next()) {
+				OrderDataBean orderData = getOrderDataFromResultSet(rs);
 				orderData.setOrderStatus("completed");
-				updateOrderStatus(conn, orderData.getOrderID(), orderData.getOrderStatus());
+				updateOrderStatus(conn, orderData.getOrderID(), orderData
+						.getOrderStatus());
 				orderDataBeans.add(orderData);
-				
+
 			}
 
 			stmt.close();
 			commit(conn);
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			Log.error("TradeDirect:getOrders -- error getting user orders", e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
 		return orderDataBeans;
 	}
 
 	/**
-	 * @see TradeServices#createQuote(String, String, BigDecimal)
-	 */
-	public QuoteDataBean createQuote(
-		String symbol,
-		String companyName,
-		BigDecimal price)
-		throws Exception {
-		
+     * @see TradeServices#createQuote(String, String, BigDecimal)
+     */
+	public QuoteDataBean createQuote(String symbol, String companyName,
+			BigDecimal price) throws Exception {
+
 		QuoteDataBean quoteData = null;
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.traceEnter("TradeDirect:createQuote - inSession(" + this.inSession + ")");
-			
+		Connection conn = null;
+		try {
+			if (Log.doTrace())
+				Log.traceEnter("TradeDirect:createQuote - inSession("
+						+ this.inSession + ")");
+
 			price = price.setScale(FinancialUtils.SCALE, FinancialUtils.ROUND);
-			double volume=0.0, change=0.0;
+			double volume = 0.0, change = 0.0;
 
 			conn = getConn();
-            PreparedStatement stmt = getStatement(conn, createQuoteSQL);
-            stmt.setString(1, symbol);			// symbol
-            stmt.setString(2, companyName);		// companyName
-            stmt.setDouble(3, volume);			// volume
-            stmt.setBigDecimal(4, price);		// price
-            stmt.setBigDecimal(5, price);		// open
-            stmt.setBigDecimal(6, price);		// low
-            stmt.setBigDecimal(7, price);		// high
-            stmt.setDouble(8, change);			// change
+			PreparedStatement stmt = getStatement(conn, createQuoteSQL);
+			stmt.setString(1, symbol); // symbol
+			stmt.setString(2, companyName); // companyName
+			stmt.setDouble(3, volume); // volume
+			stmt.setBigDecimal(4, price); // price
+			stmt.setBigDecimal(5, price); // open
+			stmt.setBigDecimal(6, price); // low
+			stmt.setBigDecimal(7, price); // high
+			stmt.setDouble(8, change); // change
 
 			stmt.executeUpdate();
 			stmt.close();
 			commit(conn);
-				
-			quoteData = new QuoteDataBean(symbol, companyName, volume, price, price, price, price, change);
-			if (Log.doTrace()) Log.traceExit("TradeDirect:createQuote");
-		}
-		catch (Exception e)
-		{
+
+			quoteData = new QuoteDataBean(symbol, companyName, volume, price,
+					price, price, price, change);
+			if (Log.doTrace())
+				Log.traceExit("TradeDirect:createQuote");
+		} catch (Exception e) {
 			Log.error("TradeDirect:createQuote -- error creating quote", e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
 		return quoteData;
 	}
-	
+
 	/**
-	 * @see TradeServices#getQuote(String)
-	 */
-	
+     * @see TradeServices#getQuote(String)
+     */
+
 	public QuoteDataBean getQuote(String symbol) throws Exception {
 		QuoteDataBean quoteData = null;
-		Connection conn=null;
+		Connection conn = null;
 		UserTransaction txn = null;
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getQuote - inSession(" + this.inSession + ")", symbol);
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:getQuote - inSession(" + this.inSession
+						+ ")", symbol);
 
 			conn = getConn();
-			quoteData = getQuote(conn, symbol);			
-			commit(conn);			
-		}
-		catch (Exception e)
-		{
+			quoteData = getQuote(conn, symbol);
+			commit(conn);
+		} catch (Exception e) {
 			Log.error("TradeDirect:getQuote -- error getting quote", e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		return quoteData;		
+		return quoteData;
 	}
-	
-	private QuoteDataBean getQuote(Connection conn, String symbol) 
-	throws Exception 
-	{
+
+	private QuoteDataBean getQuote(Connection conn, String symbol)
+			throws Exception {
 		QuoteDataBean quoteData = null;
 		PreparedStatement stmt = getStatement(conn, getQuoteSQL);
-		stmt.setString(1, symbol);			// symbol
-	
+		stmt.setString(1, symbol); // symbol
+
 		ResultSet rs = stmt.executeQuery();
-					
-		if ( !rs.next() )
-			Log.error("TradeDirect:getQuote -- failure no result.next() for symbol: " + symbol);
-				
+
+		if (!rs.next())
+			Log
+					.error("TradeDirect:getQuote -- failure no result.next() for symbol: "
+							+ symbol);
+
 		else
 			quoteData = getQuoteDataFromResultSet(rs);
 
 		stmt.close();
-		
+
 		return quoteData;
 	}
 
-	private QuoteDataBean getQuoteForUpdate(Connection conn, String symbol) 
-	throws Exception 
-	{
+	private QuoteDataBean getQuoteForUpdate(Connection conn, String symbol)
+			throws Exception {
 		QuoteDataBean quoteData = null;
 		PreparedStatement stmt = getStatement(conn, getQuoteForUpdateSQL);
-		stmt.setString(1, symbol);			// symbol
-	
+		stmt.setString(1, symbol); // symbol
+
 		ResultSet rs = stmt.executeQuery();
-					
-		if ( !rs.next() )
+
+		if (!rs.next())
 			Log.error("TradeDirect:getQuote -- failure no result.next()");
-				
+
 		else
 			quoteData = getQuoteDataFromResultSet(rs);
 
 		stmt.close();
-		
+
 		return quoteData;
-	}	
-	
+	}
+
 	/**
-	 * @see TradeServices#getAllQuotes(String)
-	 */
+     * @see TradeServices#getAllQuotes(String)
+     */
 	public Collection getAllQuotes() throws Exception {
 		Collection quotes = new ArrayList();
 		QuoteDataBean quoteData = null;
@@ -873,7 +870,7 @@
 			conn = getConn();
 
 			PreparedStatement stmt = getStatement(conn, getAllQuotesSQL);
-	
+
 			ResultSet rs = stmt.executeQuery();
 
 			while (!rs.next()) {
@@ -882,414 +879,382 @@
 			}
 
 			stmt.close();
-		}
-		catch (Exception e) {
+		} catch (Exception e) {
 			Log.error("TradeDirect:getAllQuotes", e);
 			rollBack(conn, e);
-		}
-		finally {
+		} finally {
 			releaseConn(conn);
 		}
-		
+
 		return quotes;
 	}
 
 	/**
-	 * @see TradeServices#getHoldings(String)
-	 */
+     * @see TradeServices#getHoldings(String)
+     */
 	public Collection getHoldings(String userID) throws Exception {
 		Collection holdingDataBeans = new ArrayList();
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getHoldings - inSession(" + this.inSession + ")", userID);
-			
+		Connection conn = null;
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:getHoldings - inSession("
+						+ this.inSession + ")", userID);
+
 			conn = getConn();
-            PreparedStatement stmt = getStatement(conn, getHoldingsForUserSQL);
-            stmt.setString(1, userID);
+			PreparedStatement stmt = getStatement(conn, getHoldingsForUserSQL);
+			stmt.setString(1, userID);
 
 			ResultSet rs = stmt.executeQuery();
 
-			while ( rs.next() )
-			{			
+			while (rs.next()) {
 				HoldingDataBean holdingData = getHoldingDataFromResultSet(rs);
 				holdingDataBeans.add(holdingData);
 			}
 
 			stmt.close();
 			commit(conn);
-				
-		}
-		catch (Exception e)
-		{
-			Log.error("TradeDirect:getHoldings -- error getting user holings", e);
+
+		} catch (Exception e) {
+			Log.error("TradeDirect:getHoldings -- error getting user holings",
+					e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
 		return holdingDataBeans;
 	}
 
 	/**
-	 * @see TradeServices#getHolding(Integer)
-	 */
+     * @see TradeServices#getHolding(Integer)
+     */
 	public HoldingDataBean getHolding(Integer holdingID) throws Exception {
 		HoldingDataBean holdingData = null;
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getHolding - inSession(" + this.inSession + ")", holdingID);
-			
+		Connection conn = null;
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:getHolding - inSession("
+						+ this.inSession + ")", holdingID);
+
 			conn = getConn();
 			holdingData = getHoldingData(holdingID.intValue());
 
 			commit(conn);
-				
-		}
-		catch (Exception e)
-		{
-			Log.error("TradeDirect:getHolding -- error getting holding " + holdingID + "", e);
+
+		} catch (Exception e) {
+			Log.error("TradeDirect:getHolding -- error getting holding "
+					+ holdingID + "", e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
 		return holdingData;
-	}	
+	}
 
 	/**
-	 * @see TradeServices#getAccountData(String)
-	 */
-	public AccountDataBean getAccountData(String userID)
-	throws RemoteException
-	{
-        try{
-		AccountDataBean accountData = null;
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getAccountData - inSession(" + this.inSession + ")", userID);
-			
-			conn = getConn();
-			accountData = getAccountData(conn, userID);
-			commit(conn);
-				
-		}
-		catch (Exception e)
-		{
-			Log.error("TradeDirect:getAccountData -- error getting account data", e);
-			rollBack(conn, e);
-		}
-		finally
-		{
-			releaseConn(conn);
+     * @see TradeServices#getAccountData(String)
+     */
+	public AccountDataBean getAccountData(String userID) throws RemoteException {
+		try {
+			AccountDataBean accountData = null;
+			Connection conn = null;
+			try {
+				if (Log.doTrace())
+					Log.trace("TradeDirect:getAccountData - inSession("
+							+ this.inSession + ")", userID);
+
+				conn = getConn();
+				accountData = getAccountData(conn, userID);
+				commit(conn);
+
+			} catch (Exception e) {
+				Log
+						.error(
+								"TradeDirect:getAccountData -- error getting account data",
+								e);
+				rollBack(conn, e);
+			} finally {
+				releaseConn(conn);
+			}
+			return accountData;
+		} catch (Exception e) {
+			throw new RemoteException(e.getMessage(), e);
 		}
-		return accountData;		
-        }catch (Exception e){
-           throw new RemoteException(e.getMessage(),e); 
-        }
 	}
+
 	private AccountDataBean getAccountData(Connection conn, String userID)
-	throws Exception
-	{
+			throws Exception {
 		PreparedStatement stmt = getStatement(conn, getAccountForUserSQL);
 		stmt.setString(1, userID);
 		ResultSet rs = stmt.executeQuery();
 		AccountDataBean accountData = getAccountDataFromResultSet(rs);
 		stmt.close();
-		return accountData;         
+		return accountData;
 	}
 
-	private AccountDataBean getAccountDataForUpdate(Connection conn, String userID)
-	throws Exception
-	{
-		PreparedStatement stmt = getStatement(conn, getAccountForUserForUpdateSQL);
+	private AccountDataBean getAccountDataForUpdate(Connection conn,
+			String userID) throws Exception {
+		PreparedStatement stmt = getStatement(conn,
+				getAccountForUserForUpdateSQL);
 		stmt.setString(1, userID);
 		ResultSet rs = stmt.executeQuery();
 		AccountDataBean accountData = getAccountDataFromResultSet(rs);
 		stmt.close();
-		return accountData;         
+		return accountData;
 	}
+
 	/**
-	 * @see TradeServices#getAccountData(String)
-	 */
-	public AccountDataBean getAccountData(int accountID)
-	throws Exception
-	{
+     * @see TradeServices#getAccountData(String)
+     */
+	public AccountDataBean getAccountData(int accountID) throws Exception {
 		AccountDataBean accountData = null;
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getAccountData - inSession(" + this.inSession + ")", new Integer(accountID));
-			
+		Connection conn = null;
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:getAccountData - inSession("
+						+ this.inSession + ")", new Integer(accountID));
+
 			conn = getConn();
 			accountData = getAccountData(accountID, conn);
 			commit(conn);
-				
-		}
-		catch (Exception e)
-		{
-			Log.error("TradeDirect:getAccountData -- error getting account data", e);
+
+		} catch (Exception e) {
+			Log.error(
+					"TradeDirect:getAccountData -- error getting account data",
+					e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		return accountData;		
+		return accountData;
 	}
+
 	private AccountDataBean getAccountData(int accountID, Connection conn)
-	throws Exception
-	{
+			throws Exception {
 		PreparedStatement stmt = getStatement(conn, getAccountSQL);
 		stmt.setInt(1, accountID);
 		ResultSet rs = stmt.executeQuery();
 		AccountDataBean accountData = getAccountDataFromResultSet(rs);
 		stmt.close();
-		return accountData;         
+		return accountData;
 	}
-	private AccountDataBean getAccountDataForUpdate(int accountID, Connection conn)
-	throws Exception
-	{
+
+	private AccountDataBean getAccountDataForUpdate(int accountID,
+			Connection conn) throws Exception {
 		PreparedStatement stmt = getStatement(conn, getAccountForUpdateSQL);
 		stmt.setInt(1, accountID);
 		ResultSet rs = stmt.executeQuery();
 		AccountDataBean accountData = getAccountDataFromResultSet(rs);
 		stmt.close();
-		return accountData;         
-	}	
+		return accountData;
+	}
 
-	private QuoteDataBean getQuoteData(String symbol)
-	throws Exception
-	{
+	private QuoteDataBean getQuoteData(String symbol) throws Exception {
 		QuoteDataBean quoteData = null;
-		Connection conn=null;
-		try
-		{
+		Connection conn = null;
+		try {
 			conn = getConn();
 			quoteData = getQuoteData(conn, symbol);
 			commit(conn);
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			Log.error("TradeDirect:getQuoteData -- error getting data", e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		return quoteData;		
+		return quoteData;
 	}
+
 	private QuoteDataBean getQuoteData(Connection conn, String symbol)
-	throws Exception
-	{
+			throws Exception {
 		QuoteDataBean quoteData = null;
 		PreparedStatement stmt = getStatement(conn, getQuoteSQL);
 		stmt.setString(1, symbol);
 		ResultSet rs = stmt.executeQuery();
-		if (!rs.next()) 
-			Log.error("TradeDirect:getQuoteData -- could not find quote for symbol="+symbol);
+		if (!rs.next())
+			Log
+					.error("TradeDirect:getQuoteData -- could not find quote for symbol="
+							+ symbol);
 		else
 			quoteData = getQuoteDataFromResultSet(rs);
 		stmt.close();
-		return quoteData;         
+		return quoteData;
 	}
-	
-	private HoldingDataBean getHoldingData(int holdingID)
-	throws Exception
-	{
+
+	private HoldingDataBean getHoldingData(int holdingID) throws Exception {
 		HoldingDataBean holdingData = null;
-		Connection conn=null;
-		try
-		{
+		Connection conn = null;
+		try {
 			conn = getConn();
 			holdingData = getHoldingData(conn, holdingID);
 			commit(conn);
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			Log.error("TradeDirect:getHoldingData -- error getting data", e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		return holdingData;		
+		return holdingData;
 	}
+
 	private HoldingDataBean getHoldingData(Connection conn, int holdingID)
-	throws Exception
-	{
+			throws Exception {
 		HoldingDataBean holdingData = null;
 		PreparedStatement stmt = getStatement(conn, getHoldingSQL);
 		stmt.setInt(1, holdingID);
 		ResultSet rs = stmt.executeQuery();
-		if (!rs.next()) 
-			Log.error("TradeDirect:getHoldingData -- no results -- holdingID="+holdingID);
+		if (!rs.next())
+			Log.error("TradeDirect:getHoldingData -- no results -- holdingID="
+					+ holdingID);
 		else
 			holdingData = getHoldingDataFromResultSet(rs);
 
 		stmt.close();
-		return holdingData;         
+		return holdingData;
 	}
 
-	private OrderDataBean getOrderData(int orderID)
-	throws Exception
-	{
+	private OrderDataBean getOrderData(int orderID) throws Exception {
 		OrderDataBean orderData = null;
-		Connection conn=null;
-		try
-		{
+		Connection conn = null;
+		try {
 			conn = getConn();
 			orderData = getOrderData(conn, orderID);
 			commit(conn);
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			Log.error("TradeDirect:getOrderData -- error getting data", e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		return orderData;		
+		return orderData;
 	}
+
 	private OrderDataBean getOrderData(Connection conn, int orderID)
-	throws Exception
-	{
+			throws Exception {
 		OrderDataBean orderData = null;
-		if (Log.doTrace()) Log.trace("TradeDirect:getOrderData(conn, " + orderID + ")");		
+		if (Log.doTrace())
+			Log.trace("TradeDirect:getOrderData(conn, " + orderID + ")");
 		PreparedStatement stmt = getStatement(conn, getOrderSQL);
 		stmt.setInt(1, orderID);
-		ResultSet rs = stmt.executeQuery();		
+		ResultSet rs = stmt.executeQuery();
 		if (!rs.next())
-			Log.error("TradeDirect:getOrderData -- no results for orderID:" + orderID);	
+			Log.error("TradeDirect:getOrderData -- no results for orderID:"
+					+ orderID);
 		else
 			orderData = getOrderDataFromResultSet(rs);
 		stmt.close();
-		return orderData;         
+		return orderData;
 	}
 
-	
 	/**
-	 * @see TradeServices#getAccountProfileData(String)
-	 */
+     * @see TradeServices#getAccountProfileData(String)
+     */
 	public AccountProfileDataBean getAccountProfileData(String userID)
-	throws Exception
-	{
+			throws Exception {
 		AccountProfileDataBean accountProfileData = null;
-		Connection conn=null;
-	
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getAccountProfileData - inSession(" + this.inSession + ")", userID);
-			
+		Connection conn = null;
+
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:getAccountProfileData - inSession("
+						+ this.inSession + ")", userID);
+
 			conn = getConn();
 			accountProfileData = getAccountProfileData(conn, userID);
 			commit(conn);
-		}
-		catch (Exception e)
-		{
-			Log.error("TradeDirect:getAccountProfileData -- error getting profile data", e);
+		} catch (Exception e) {
+			Log
+					.error(
+							"TradeDirect:getAccountProfileData -- error getting profile data",
+							e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		return accountProfileData;		
+		return accountProfileData;
 	}
-	private AccountProfileDataBean getAccountProfileData(Connection conn, String userID)
-	throws Exception
-	{
+
+	private AccountProfileDataBean getAccountProfileData(Connection conn,
+			String userID) throws Exception {
 		PreparedStatement stmt = getStatement(conn, getAccountProfileSQL);
 		stmt.setString(1, userID);
 
 		ResultSet rs = stmt.executeQuery();
-			
+
 		AccountProfileDataBean accountProfileData = getAccountProfileDataFromResultSet(rs);
 		stmt.close();
 		return accountProfileData;
 	}
-		
 
 	private AccountProfileDataBean getAccountProfileData(Integer accountID)
-	throws Exception
-	{
+			throws Exception {
 		AccountProfileDataBean accountProfileData = null;
-		Connection conn=null;
-	
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:getAccountProfileData", accountID);
-			
+		Connection conn = null;
+
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:getAccountProfileData", accountID);
+
 			conn = getConn();
 			accountProfileData = getAccountProfileData(conn, accountID);
 			commit(conn);
-		}
-		catch (Exception e)
-		{
-			Log.error("TradeDirect:getAccountProfileData -- error getting profile data", e);
+		} catch (Exception e) {
+			Log
+					.error(
+							"TradeDirect:getAccountProfileData -- error getting profile data",
+							e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		return accountProfileData;		
+		return accountProfileData;
 	}
-	private AccountProfileDataBean getAccountProfileData(Connection conn, Integer accountID)
-	throws Exception
-	{
-		PreparedStatement stmt = getStatement(conn, getAccountProfileForAccountSQL);
+
+	private AccountProfileDataBean getAccountProfileData(Connection conn,
+			Integer accountID) throws Exception {
+		PreparedStatement stmt = getStatement(conn,
+				getAccountProfileForAccountSQL);
 		stmt.setInt(1, accountID.intValue());
 
 		ResultSet rs = stmt.executeQuery();
-			
+
 		AccountProfileDataBean accountProfileData = getAccountProfileDataFromResultSet(rs);
 		stmt.close();
 		return accountProfileData;
 	}
-	
 
 	/**
-	 * @see TradeServices#updateAccountProfile(AccountProfileDataBean)
-	 */
-	public AccountProfileDataBean updateAccountProfile(AccountProfileDataBean profileData)
-	throws Exception {
+     * @see TradeServices#updateAccountProfile(AccountProfileDataBean)
+     */
+	public AccountProfileDataBean updateAccountProfile(
+			AccountProfileDataBean profileData) throws Exception {
 		AccountProfileDataBean accountProfileData = null;
-		Connection conn=null;
-	
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:updateAccountProfileData - inSession(" + this.inSession + ")", profileData.getUserID());
-			
+		Connection conn = null;
+
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:updateAccountProfileData - inSession("
+						+ this.inSession + ")", profileData.getUserID());
+
 			conn = getConn();
-			updateAccountProfile(conn, profileData);	
+			updateAccountProfile(conn, profileData);
 
-			accountProfileData = getAccountProfileData(conn, profileData.getUserID());
+			accountProfileData = getAccountProfileData(conn, profileData
+					.getUserID());
 			commit(conn);
-		}
-		catch (Exception e)
-		{
-			Log.error("TradeDirect:getAccountProfileData -- error getting profile data", e);
+		} catch (Exception e) {
+			Log
+					.error(
+							"TradeDirect:getAccountProfileData -- error getting profile data",
+							e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		return accountProfileData;		
+		return accountProfileData;
 	}
 
-	private void creditAccountBalance(Connection conn, AccountDataBean accountData, BigDecimal credit)
-		throws Exception
-	{
+	private void creditAccountBalance(Connection conn,
+			AccountDataBean accountData, BigDecimal credit) throws Exception {
 		PreparedStatement stmt = getStatement(conn, creditAccountBalanceSQL);
 
 		stmt.setBigDecimal(1, credit);
@@ -1297,50 +1262,46 @@
 
 		int count = stmt.executeUpdate();
 		stmt.close();
-		
-	}
 
+	}
 
-    // Set Timestamp to zero to denote sell is inflight
-    // UPDATE  -- could add a "status" attribute to holding
-	private void updateHoldingStatus(Connection conn, Integer holdingID, String symbol)
-		throws Exception
-	{
+	// Set Timestamp to zero to denote sell is inflight
+	// UPDATE -- could add a "status" attribute to holding
+	private void updateHoldingStatus(Connection conn, Integer holdingID,
+			String symbol) throws Exception {
 		Timestamp ts = new Timestamp(0);
-		PreparedStatement stmt = getStatement(conn, "update holdingejb set purchasedate= ? where holdingid = ?");
+		PreparedStatement stmt = getStatement(conn,
+				"update holdingejb set purchasedate= ? where holdingid = ?");
 
 		stmt.setTimestamp(1, ts);
 		stmt.setInt(2, holdingID.intValue());
 		int count = stmt.executeUpdate();
-		stmt.close();	
+		stmt.close();
 	}
 
-	private void updateOrderStatus(Connection conn, Integer orderID, String status)
-		throws Exception
-	{
+	private void updateOrderStatus(Connection conn, Integer orderID,
+			String status) throws Exception {
 		PreparedStatement stmt = getStatement(conn, updateOrderStatusSQL);
 
 		stmt.setString(1, status);
 		stmt.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
 		stmt.setInt(3, orderID.intValue());
 		int count = stmt.executeUpdate();
-		stmt.close();	
+		stmt.close();
 	}
-	
+
 	private void updateOrderHolding(Connection conn, int orderID, int holdingID)
-		throws Exception
-	{
+			throws Exception {
 		PreparedStatement stmt = getStatement(conn, updateOrderHoldingSQL);
 
 		stmt.setInt(1, holdingID);
 		stmt.setInt(2, orderID);
 		int count = stmt.executeUpdate();
-		stmt.close();	
+		stmt.close();
 	}
-	
-	private void updateAccountProfile(Connection conn, AccountProfileDataBean profileData)
-		throws Exception	
-	{
+
+	private void updateAccountProfile(Connection conn,
+			AccountProfileDataBean profileData) throws Exception {
 		PreparedStatement stmt = getStatement(conn, updateAccountProfileSQL);
 
 		stmt.setString(1, profileData.getPassword());
@@ -1348,49 +1309,57 @@
 		stmt.setString(3, profileData.getAddress());
 		stmt.setString(4, profileData.getEmail());
 		stmt.setString(5, profileData.getCreditCard());
-		stmt.setString(6, profileData.getUserID());                                                            
+		stmt.setString(6, profileData.getUserID());
 
 		int count = stmt.executeUpdate();
 		stmt.close();
 	}
-	
-	private void updateQuoteVolume(Connection conn, QuoteDataBean quoteData, double quantity)
-		throws Exception	
-	{
+
+	private void updateQuoteVolume(Connection conn, QuoteDataBean quoteData,
+			double quantity) throws Exception {
 		PreparedStatement stmt = getStatement(conn, updateQuoteVolumeSQL);
 
 		stmt.setDouble(1, quantity);
 		stmt.setString(2, quoteData.getSymbol());
 
 		int count = stmt.executeUpdate();
-		stmt.close();	
+		stmt.close();
 	}
 
-	public QuoteDataBean updateQuotePriceVolume(String symbol, BigDecimal changeFactor, double sharesTraded) throws Exception {
-		return updateQuotePriceVolumeInt(symbol, changeFactor, sharesTraded, TradeConfig.getPublishQuotePriceChange());
+	public QuoteDataBean updateQuotePriceVolume(String symbol,
+			BigDecimal changeFactor, double sharesTraded) throws Exception {
+		return updateQuotePriceVolumeInt(symbol, changeFactor, sharesTraded,
+				TradeConfig.getPublishQuotePriceChange());
 	}
 
 	/**
-	 * Update a quote's price and volume
-	 * @param symbol The PK of the quote
-	 * @param changeFactor the percent to change the old price by (between 50% and 150%)
-	 * @param sharedTraded the ammount to add to the current volume
-	 * @param publishQuotePriceChange used by the PingJDBCWrite Primitive to ensure no JMS is used, should
-	 *   be true for all normal calls to this API
-	 */
-	public QuoteDataBean updateQuotePriceVolumeInt(String symbol, BigDecimal changeFactor, double sharesTraded, boolean publishQuotePriceChange)
-		throws Exception	
-	{
-		
-		if ( TradeConfig.getUpdateQuotePrices() == false ) 
-			return new QuoteDataBean();	
-		
+     * Update a quote's price and volume
+     * 
+     * @param symbol
+     *            The PK of the quote
+     * @param changeFactor
+     *            the percent to change the old price by (between 50% and 150%)
+     * @param sharedTraded
+     *            the ammount to add to the current volume
+     * @param publishQuotePriceChange
+     *            used by the PingJDBCWrite Primitive to ensure no JMS is used,
+     *            should be true for all normal calls to this API
+     */
+	public QuoteDataBean updateQuotePriceVolumeInt(String symbol,
+			BigDecimal changeFactor, double sharesTraded,
+			boolean publishQuotePriceChange) throws Exception {
+
+		if (TradeConfig.getUpdateQuotePrices() == false)
+			return new QuoteDataBean();
+
 		QuoteDataBean quoteData = null;
-		Connection conn=null;
+		Connection conn = null;
 		UserTransaction txn = null;
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:updateQuotePriceVolume - inSession(" + this.inSession + ")", symbol, changeFactor, new Double(sharesTraded));		
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:updateQuotePriceVolume - inSession("
+						+ this.inSession + ")", symbol, changeFactor,
+						new Double(sharesTraded));
 
 			conn = getConn();
 
@@ -1404,446 +1373,407 @@
 				changeFactor = TradeConfig.MAXIMUM_STOCK_SPLIT_MULTIPLIER;
 			}
 
-			BigDecimal newPrice = changeFactor.multiply(oldPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
+			BigDecimal newPrice = changeFactor.multiply(oldPrice).setScale(2,
+					BigDecimal.ROUND_HALF_UP);
 
-			updateQuotePriceVolume(conn, quoteData.getSymbol(), newPrice, newVolume);				
+			updateQuotePriceVolume(conn, quoteData.getSymbol(), newPrice,
+					newVolume);
 			quoteData = getQuote(conn, symbol);
 
-			commit(conn);		
+			commit(conn);
 
 			if (publishQuotePriceChange) {
-				publishQuotePriceChange(quoteData, oldPrice, changeFactor, sharesTraded);			
+				publishQuotePriceChange(quoteData, oldPrice, changeFactor,
+						sharesTraded);
 			}
-			
-		}
-		catch (Exception e)
-		{
-			Log.error("TradeDirect:updateQuotePriceVolume -- error updating quote price/volume for symbol:" + symbol);
+
+		} catch (Exception e) {
+			Log
+					.error("TradeDirect:updateQuotePriceVolume -- error updating quote price/volume for symbol:"
+							+ symbol);
 			rollBack(conn, e);
 			throw e;
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		return quoteData;		
+		return quoteData;
 	}
 
-	private void updateQuotePriceVolume(Connection conn, String symbol, BigDecimal newPrice, double newVolume)
-		throws Exception	
-	{		
+	private void updateQuotePriceVolume(Connection conn, String symbol,
+			BigDecimal newPrice, double newVolume) throws Exception {
 
 		PreparedStatement stmt = getStatement(conn, updateQuotePriceVolumeSQL);
 
 		stmt.setBigDecimal(1, newPrice);
-		stmt.setBigDecimal(2, newPrice);		
-		stmt.setDouble(3, newVolume);				
+		stmt.setBigDecimal(2, newPrice);
+		stmt.setDouble(3, newVolume);
 		stmt.setString(4, symbol);
 
 		int count = stmt.executeUpdate();
-		stmt.close();	
+		stmt.close();
 	}
-	private void publishQuotePriceChange(QuoteDataBean quoteData, BigDecimal oldPrice, BigDecimal changeFactor, double sharesTraded)
-	throws Exception
-	{
+
+	private void publishQuotePriceChange(QuoteDataBean quoteData,
+			BigDecimal oldPrice, BigDecimal changeFactor, double sharesTraded)
+			throws Exception {
 		if (Log.doTrace())
-			Log.trace("TradeDirect:publishQuotePrice PUBLISHING to MDB quoteData = " + quoteData);		
+			Log
+					.trace("TradeDirect:publishQuotePrice PUBLISHING to MDB quoteData = "
+							+ quoteData);
 
-		javax.jms.Connection conn = null;	
+		javax.jms.Connection conn = null;
 		Session sess = null;
-		
-		try
-		{
-			conn = tConnFactory.createConnection();		            					
+
+		try {
+			conn = tConnFactory.createConnection();
 			sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
 			MessageProducer producer = sess.createProducer(streamerTopic);
 			TextMessage message = sess.createTextMessage();
-	
+
 			String command = "updateQuote";
 			message.setStringProperty("command", command);
-			message.setStringProperty("symbol",  quoteData.getSymbol() );
-			message.setStringProperty("company", quoteData.getCompanyName() );		
-			message.setStringProperty("price",   quoteData.getPrice().toString());
-			message.setStringProperty("oldPrice",oldPrice.toString());				
-			message.setStringProperty("open",    quoteData.getOpen().toString());
-			message.setStringProperty("low",     quoteData.getLow().toString());
-			message.setStringProperty("high",    quoteData.getHigh().toString());
-			message.setDoubleProperty("volume",  quoteData.getVolume());		
-					
-			message.setStringProperty("changeFactor", changeFactor.toString());		
-			message.setDoubleProperty("sharesTraded", sharesTraded);				
-			message.setLongProperty("publishTime", System.currentTimeMillis());					
-			message.setText("Update Stock price for " + quoteData.getSymbol() + " old price = " + oldPrice + " new price = " + quoteData.getPrice());
+			message.setStringProperty("symbol", quoteData.getSymbol());
+			message.setStringProperty("company", quoteData.getCompanyName());
+			message.setStringProperty("price", quoteData.getPrice().toString());
+			message.setStringProperty("oldPrice", oldPrice.toString());
+			message.setStringProperty("open", quoteData.getOpen().toString());
+			message.setStringProperty("low", quoteData.getLow().toString());
+			message.setStringProperty("high", quoteData.getHigh().toString());
+			message.setDoubleProperty("volume", quoteData.getVolume());
+
+			message.setStringProperty("changeFactor", changeFactor.toString());
+			message.setDoubleProperty("sharesTraded", sharesTraded);
+			message.setLongProperty("publishTime", System.currentTimeMillis());
+			message.setText("Update Stock price for " + quoteData.getSymbol()
+					+ " old price = " + oldPrice + " new price = "
+					+ quoteData.getPrice());
 
 			producer.send(message);
+		} catch (Exception e) {
+			throw e; // pass exception back
+
 		}
-		catch (Exception e)
-		{
-			throw e; //pass exception back
-			
-		}
-		
-		finally
-		{
-			if (sess != null)	
+
+		finally {
+			if (sess != null)
 				sess.close();
 			if (conn != null)
-				conn.close();					
-		}	
-	}		
-
+				conn.close();
+		}
+	}
 
 	/**
-	 * @see TradeServices#login(String, String)
-	 */
-	
+     * @see TradeServices#login(String, String)
+     */
+
 	public AccountDataBean login(String userID, String password)
-	throws Exception {
+			throws Exception {
 
 		AccountDataBean accountData = null;
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.trace("TradeDirect:login - inSession(" + this.inSession + ")", userID, password);
-			
+		Connection conn = null;
+		try {
+			if (Log.doTrace())
+				Log.trace("TradeDirect:login - inSession(" + this.inSession
+						+ ")", userID, password);
+
 			conn = getConn();
-            PreparedStatement stmt = getStatement(conn, getAccountProfileSQL);
-            stmt.setString(1, userID);
+			PreparedStatement stmt = getStatement(conn, getAccountProfileSQL);
+			stmt.setString(1, userID);
 
 			ResultSet rs = stmt.executeQuery();
-			if ( !rs.next() )
-			{
-				Log.error("TradeDirect:login -- failure to find account for" + userID);
-				throw new javax.ejb.FinderException("Cannot find account for" + userID);
+			if (!rs.next()) {
+				Log.error("TradeDirect:login -- failure to find account for"
+						+ userID);
+				throw new javax.ejb.FinderException("Cannot find account for"
+						+ userID);
 			}
-				
+
 			String pw = rs.getString("passwd");
 			stmt.close();
-	    	if ( (pw==null) || (pw.equals(password) == false) )
-	    	{
-   	 			String error = "TradeDirect:Login failure for user: " + userID + 
-    						"\n\tIncorrect password-->" + userID + ":" + password;
-    			Log.error(error);
- 		   		throw new Exception(error);
-	    	}
-	    	
+			if ((pw == null) || (pw.equals(password) == false)) {
+				String error = "TradeDirect:Login failure for user: " + userID
+						+ "\n\tIncorrect password-->" + userID + ":" + password;
+				Log.error(error);
+				throw new Exception(error);
+			}
+
 			stmt = getStatement(conn, loginSQL);
 			stmt.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
-                        stmt.setString(2, userID);
+			stmt.setString(2, userID);
 
 			int rows = stmt.executeUpdate();
-			//?assert rows==1?
-		        stmt.close();
-	
+			// ?assert rows==1?
+			stmt.close();
+
 			stmt = getStatement(conn, getAccountForUserSQL);
 			stmt.setString(1, userID);
 			rs = stmt.executeQuery();
 
 			accountData = getAccountDataFromResultSet(rs);
-			
+
 			stmt.close();
-		
+
 			commit(conn);
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			Log.error("TradeDirect:login -- error logging in user", e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
-		return accountData;		
+		return accountData;
 
 		/*
-    	setLastLogin( new Timestamp(System.currentTimeMillis()) );
-    	setLoginCount( getLoginCount() + 1 );
-        */
+         * setLastLogin( new Timestamp(System.currentTimeMillis()) );
+         * setLoginCount( getLoginCount() + 1 );
+         */
 	}
-	
+
 	/**
-	 * @see TradeServices#logout(String)
-	 */
+     * @see TradeServices#logout(String)
+     */
 	public void logout(String userID) throws Exception {
-		if (Log.doTrace()) Log.trace("TradeDirect:logout - inSession(" + this.inSession + ")", userID);
-		Connection conn=null;
-		try
-		{		
+		if (Log.doTrace())
+			Log.trace("TradeDirect:logout - inSession(" + this.inSession + ")",
+					userID);
+		Connection conn = null;
+		try {
 			conn = getConn();
-            PreparedStatement stmt = getStatement(conn, logoutSQL);
-            stmt.setString(1, userID);        
+			PreparedStatement stmt = getStatement(conn, logoutSQL);
+			stmt.setString(1, userID);
 			stmt.executeUpdate();
 			stmt.close();
 
 			commit(conn);
-		}
-		catch (Exception e)
-		{
+		} catch (Exception e) {
 			Log.error("TradeDirect:logout -- error logging out user", e);
 			rollBack(conn, e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
 	}
 
 	/**
-	 * @see TradeServices#register(String, String, String, String, String, String, BigDecimal, boolean)
-	 */
+     * @see TradeServices#register(String, String, String, String, String,
+     *      String, BigDecimal, boolean)
+     */
+
+	public AccountDataBean register(String userID, String password,
+			String fullname, String address, String email, String creditcard,
+			BigDecimal openBalance) throws Exception {
 
-	public AccountDataBean register(
-		String userID,
-		String password,
-		String fullname,
-		String address,
-		String email,
-		String creditcard,
-		BigDecimal openBalance)
-		throws Exception {
-			
 		AccountDataBean accountData = null;
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.traceEnter("TradeDirect:register - inSession(" + this.inSession + ")");
-			
+		Connection conn = null;
+		try {
+			if (Log.doTrace())
+				Log.traceEnter("TradeDirect:register - inSession("
+						+ this.inSession + ")");
+
 			conn = getConn();
-            PreparedStatement stmt = getStatement(conn, createAccountSQL);
+			PreparedStatement stmt = getStatement(conn, createAccountSQL);
 
-			Integer accountID = KeySequenceDirect.getNextID(conn, "account", inSession, getInGlobalTxn());
+			Integer accountID = KeySequenceDirect.getNextID(conn, "account",
+					inSession, getInGlobalTxn());
 			BigDecimal balance = openBalance;
 			Timestamp creationDate = new Timestamp(System.currentTimeMillis());
-			Timestamp lastLogin  = creationDate;
-			int  loginCount = 0;
-			int  logoutCount = 0;
-			
-            stmt.setInt(1, accountID.intValue());			
-            stmt.setTimestamp(2, creationDate);
-            stmt.setBigDecimal(3, openBalance);
-            stmt.setBigDecimal(4, balance);  
-            stmt.setTimestamp(5, lastLogin);
-            stmt.setInt(6, loginCount);
-            stmt.setInt(7, logoutCount);
-            stmt.setString(8, userID);        
+			Timestamp lastLogin = creationDate;
+			int loginCount = 0;
+			int logoutCount = 0;
+
+			stmt.setInt(1, accountID.intValue());
+			stmt.setTimestamp(2, creationDate);
+			stmt.setBigDecimal(3, openBalance);
+			stmt.setBigDecimal(4, balance);
+			stmt.setTimestamp(5, lastLogin);
+			stmt.setInt(6, loginCount);
+			stmt.setInt(7, logoutCount);
+			stmt.setString(8, userID);
 			stmt.executeUpdate();
 			stmt.close();
-			
-            stmt = getStatement(conn, createAccountProfileSQL);
-			stmt.setString(1, userID);        
-			stmt.setString(2, password);        
+
+			stmt = getStatement(conn, createAccountProfileSQL);
+			stmt.setString(1, userID);
+			stmt.setString(2, password);
 			stmt.setString(3, fullname);
 			stmt.setString(4, address);
-			stmt.setString(5, email);			
+			stmt.setString(5, email);
 			stmt.setString(6, creditcard);
 			stmt.executeUpdate();
 			stmt.close();
-									
+
 			commit(conn);
-				
-			accountData = new AccountDataBean(accountID, loginCount, logoutCount, lastLogin, creationDate, balance, openBalance, userID);
-			if (Log.doTrace()) Log.traceExit("TradeDirect:register");
-		}
-		catch (Exception e)
-		{
+
+			accountData = new AccountDataBean(accountID, loginCount,
+					logoutCount, lastLogin, creationDate, balance, openBalance,
+					userID);
+			if (Log.doTrace())
+				Log.traceExit("TradeDirect:register");
+		} catch (Exception e) {
 			Log.error("TradeDirect:register -- error registering new user", e);
-		}
-		finally
-		{
+		} finally {
 			releaseConn(conn);
 		}
 		return accountData;
 	}
 
 	private AccountDataBean getAccountDataFromResultSet(ResultSet rs)
-	throws Exception
-	{
+			throws Exception {
 		AccountDataBean accountData = null;
 
+		if (!rs.next())
+			Log
+					.error("TradeDirect:getAccountDataFromResultSet -- cannot find account data");
 
-		if (!rs.next() )
-			Log.error("TradeDirect:getAccountDataFromResultSet -- cannot find account data");
-				
 		else
-			accountData = new AccountDataBean(
-				new Integer(rs.getInt("accountID")),
-				rs.getInt("loginCount"),
-				rs.getInt("logoutCount"),
-				rs.getTimestamp("lastLogin"),
-				rs.getTimestamp("creationDate"),
-				rs.getBigDecimal("balance"),
-				rs.getBigDecimal("openBalance"),
-				rs.getString("profile_userID")			
-			);
+			accountData = new AccountDataBean(new Integer(rs
+					.getInt("accountID")), rs.getInt("loginCount"), rs
+					.getInt("logoutCount"), rs.getTimestamp("lastLogin"), rs
+					.getTimestamp("creationDate"), rs.getBigDecimal("balance"),
+					rs.getBigDecimal("openBalance"), rs
+							.getString("profile_userID"));
 		return accountData;
 	}
 
-	private AccountProfileDataBean getAccountProfileDataFromResultSet(ResultSet rs)
-	throws Exception
-	{
+	private AccountProfileDataBean getAccountProfileDataFromResultSet(
+			ResultSet rs) throws Exception {
 		AccountProfileDataBean accountProfileData = null;
 
-		if (!rs.next() )
-			Log.error("TradeDirect:getAccountProfileDataFromResultSet -- cannot find accountprofile data");
-		else			
-			accountProfileData = new AccountProfileDataBean(
-				rs.getString("userID"),
-				rs.getString("passwd"),
-				rs.getString("fullName"),
-				rs.getString("address"),
-				rs.getString("email"),
-				rs.getString("creditCard")
-			);
-			
+		if (!rs.next())
+			Log
+					.error("TradeDirect:getAccountProfileDataFromResultSet -- cannot find accountprofile data");
+		else
+			accountProfileData = new AccountProfileDataBean(rs
+					.getString("userID"), rs.getString("passwd"), rs
+					.getString("fullName"), rs.getString("address"), rs
+					.getString("email"), rs.getString("creditCard"));
+
 		return accountProfileData;
 	}
 
 	private HoldingDataBean getHoldingDataFromResultSet(ResultSet rs)
-	throws Exception
-	{
+			throws Exception {
 		HoldingDataBean holdingData = null;
 
-		holdingData = new HoldingDataBean(
-			new Integer(rs.getInt("holdingID")),
-			rs.getDouble("quantity"),
-			rs.getBigDecimal("purchasePrice"),
-			rs.getTimestamp("purchaseDate"),
-			rs.getString("quote_symbol")
-		);
+		holdingData = new HoldingDataBean(new Integer(rs.getInt("holdingID")),
+				rs.getDouble("quantity"), rs.getBigDecimal("purchasePrice"), rs
+						.getTimestamp("purchaseDate"), rs
+						.getString("quote_symbol"));
 		return holdingData;
 	}
-	
+
 	private QuoteDataBean getQuoteDataFromResultSet(ResultSet rs)
-	throws Exception
-	{
+			throws Exception {
 		QuoteDataBean quoteData = null;
 
-		quoteData = new QuoteDataBean(
-			rs.getString("symbol"),
-			rs.getString("companyName"),
-			rs.getDouble("volume"),
-			rs.getBigDecimal("price"),
-			rs.getBigDecimal("open1"),
-			rs.getBigDecimal("low"),
-			rs.getBigDecimal("high"),
-			rs.getDouble("change1")
-		);
+		quoteData = new QuoteDataBean(rs.getString("symbol"), rs
+				.getString("companyName"), rs.getDouble("volume"), rs
+				.getBigDecimal("price"), rs.getBigDecimal("open1"), rs
+				.getBigDecimal("low"), rs.getBigDecimal("high"), rs
+				.getDouble("change1"));
 		return quoteData;
 	}
 
 	private OrderDataBean getOrderDataFromResultSet(ResultSet rs)
-	throws Exception
-	{
+			throws Exception {
 		OrderDataBean orderData = null;
 
-		orderData = new OrderDataBean(
-			new Integer(rs.getInt("orderID")),
-			rs.getString("orderType"),
-			rs.getString("orderStatus"),
-			rs.getTimestamp("openDate"),
-			rs.getTimestamp("completionDate"),
-			rs.getDouble("quantity"),
-			rs.getBigDecimal("price"),
-			rs.getBigDecimal("orderFee"),
-			rs.getString("quote_symbol")
-		);
+		orderData = new OrderDataBean(new Integer(rs.getInt("orderID")), rs
+				.getString("orderType"), rs.getString("orderStatus"), rs
+				.getTimestamp("openDate"), rs.getTimestamp("completionDate"),
+				rs.getDouble("quantity"), rs.getBigDecimal("price"), rs
+						.getBigDecimal("orderFee"), rs
+						.getString("quote_symbol"));
 		return orderData;
 	}
-	
-	public String checkDBProductName() throws Exception
-	{
+
+	public String checkDBProductName() throws Exception {
 		Connection conn = null;
 		String dbProductName = null;
-		
-		try
-		{
-			if (Log.doTrace()) Log.traceEnter("TradeDirect:checkDBProductName");
-			
+
+		try {
+			if (Log.doTrace())
+				Log.traceEnter("TradeDirect:checkDBProductName");
+
 			conn = getConn();
 			DatabaseMetaData dbmd = conn.getMetaData();
 			dbProductName = dbmd.getDatabaseProductName();
-		}
-		catch (SQLException e)
-		{
-			Log.error(e,"TradeDirect:checkDBProductName() -- Error checking the Daytrader Database Product Name");
-		}
-		finally
-		{
+		} catch (SQLException e) {
+			Log
+					.error(
+							e,
+							"TradeDirect:checkDBProductName() -- Error checking the Daytrader Database Product Name");
+		} finally {
 			releaseConn(conn);
 		}
 		return dbProductName;
 	}
-	
-	public boolean recreateDBTables(Object[] sqlBuffer, java.io.PrintWriter out) throws Exception
-	{
-		//Clear MDB Statistics		
+
+	public boolean recreateDBTables(Object[] sqlBuffer, java.io.PrintWriter out)
+			throws Exception {
+		// Clear MDB Statistics
 		MDBStats.getInstance().reset();
-		
+
 		Connection conn = null;
 		boolean success = false;
-		try
-		{
-			if (Log.doTrace()) Log.traceEnter("TradeDirect:recreateDBTables");
-			
+		try {
+			if (Log.doTrace())
+				Log.traceEnter("TradeDirect:recreateDBTables");
+
 			conn = getConn();
 			Statement stmt = conn.createStatement();
 			int bufferLength = sqlBuffer.length;
-			for (int i = 0; i< bufferLength; i++)
-			{
-				try
-				{
-					stmt.executeUpdate((String)sqlBuffer[i]);
-					//commit(conn);
-				}
-				catch(SQLException ex) 
-				{
+			for (int i = 0; i < bufferLength; i++) {
+				try {
+					stmt.executeUpdate((String) sqlBuffer[i]);
+					// commit(conn);
+				} catch (SQLException ex) {
 					// Ignore DROP statements as tables won't always exist.
-					if (((String)sqlBuffer[i]).indexOf("DROP TABLE") < 0) { 
-                	    Log.error("TradeDirect:recreateDBTables SQL Exception thrown on executing the foll sql command: " + sqlBuffer[i], ex);
-                        out.println("<BR>SQL Exception thrown on executing the foll sql command: <I>" + sqlBuffer[i] + "</I> . Check log for details.</BR>");
+					if (((String) sqlBuffer[i]).indexOf("DROP TABLE") < 0) {
+						Log
+								.error(
+										"TradeDirect:recreateDBTables SQL Exception thrown on executing the foll sql command: "
+												+ sqlBuffer[i], ex);
+						out
+								.println("<BR>SQL Exception thrown on executing the foll sql command: <I>"
+										+ sqlBuffer[i]
+										+ "</I> . Check log for details.</BR>");
 					}
-                }
+				}
 			}
 			stmt.close();
-            commit(conn);
-            success = true;
-		}
-		catch (Exception e)
-		{
-			Log.error(e,"TradeDirect:recreateDBTables() -- Error dropping and recreating the database tables");
-		}
-		finally
-		{
+			commit(conn);
+			success = true;
+		} catch (Exception e) {
+			Log
+					.error(
+							e,
+							"TradeDirect:recreateDBTables() -- Error dropping and recreating the database tables");
+		} finally {
 			releaseConn(conn);
 		}
 		return success;
 	}
-	
-	public RunStatsDataBean resetTrade(boolean deleteAll)
-	throws Exception
-	{
-		//Clear MDB Statistics		
+
+	public RunStatsDataBean resetTrade(boolean deleteAll) throws Exception {
+		// Clear MDB Statistics
 		MDBStats.getInstance().reset();
-		// Reset Trade		
+		// Reset Trade
 
 		RunStatsDataBean runStatsData = new RunStatsDataBean();
-		Connection conn=null;
-		try
-		{
-			if (Log.doTrace()) Log.traceEnter("TradeDirect:resetTrade deleteAll rows=" + deleteAll);
-	
+		Connection conn = null;
+		try {
+			if (Log.doTrace())
+				Log.traceEnter("TradeDirect:resetTrade deleteAll rows="
+						+ deleteAll);
+
 			conn = getConn();
-			PreparedStatement stmt=null;
+			PreparedStatement stmt = null;
 			ResultSet rs = null;
-			
-			if (deleteAll)
-			{
-				try
-				{
+
+			if (deleteAll) {
+				try {
 					stmt = getStatement(conn, "delete from quoteejb");
 					stmt.executeUpdate();
-					stmt.close();				
+					stmt.close();
 					stmt = getStatement(conn, "delete from accountejb");
 					stmt.executeUpdate();
 					stmt.close();
@@ -1857,510 +1787,491 @@
 					stmt.executeUpdate();
 					stmt.close();
 					// FUTURE: - DuplicateKeyException - For now, don't start at
-					// zero as KeySequenceDirect and KeySequenceBean will still give out
-					// the cached Block and then notice this change.  Better solution is
+					// zero as KeySequenceDirect and KeySequenceBean will still
+                    // give out
+					// the cached Block and then notice this change. Better
+                    // solution is
 					// to signal both classes to drop their cached blocks
-					//stmt = getStatement(conn, "delete from keygenejb");
-					//stmt.executeUpdate();
-					//stmt.close();
+					// stmt = getStatement(conn, "delete from keygenejb");
+					// stmt.executeUpdate();
+					// stmt.close();
 					commit(conn);
-				}
-				catch (Exception e)
-				{
-					Log.error(e,"TradeDirect:resetTrade(deleteAll) -- Error deleting Trade users and stock from the Trade database");
+				} catch (Exception e) {
+					Log
+							.error(
+									e,
+									"TradeDirect:resetTrade(deleteAll) -- Error deleting Trade users and stock from the Trade database");
 				}
 				return runStatsData;
 			}
 
-            stmt = getStatement(conn, "delete from holdingejb where holdingejb.account_accountid is null");
-            int x = stmt.executeUpdate();
-            stmt.close();			
-			
-			//Count and Delete newly registered users (users w/ id that start "ru:%":
-            stmt = getStatement(conn, "delete from accountprofileejb where userid like 'ru:%'");
-            int rowCount = stmt.executeUpdate();
-            stmt.close();
-			
-            stmt = getStatement(conn, "delete from orderejb where account_accountid in (select accountid from accountejb a where a.profile_userid like 'ru:%')");
-            rowCount = stmt.executeUpdate();
-            stmt.close();
-
-            stmt = getStatement(conn, "delete from holdingejb where account_accountid in (select accountid from accountejb a where a.profile_userid like 'ru:%')");
-            rowCount = stmt.executeUpdate();
-            stmt.close();
-            
-            stmt = getStatement(conn, "delete from accountejb where profile_userid like 'ru:%'");
-            int newUserCount = stmt.executeUpdate();
-            runStatsData.setNewUserCount(newUserCount);
-            stmt.close();           
-
-			//Count of trade users			
-            stmt = getStatement(conn, "select count(accountid) as \"tradeUserCount\" from accountejb a where a.profile_userid like 'uid:%'");
-            rs = stmt.executeQuery();
-            rs.next();
-            int tradeUserCount = rs.getInt("tradeUserCount");
-            runStatsData.setTradeUserCount(tradeUserCount);
-            stmt.close();
-            
-            rs.close();
-			//Count of trade stocks			
-            stmt = getStatement(conn, "select count(symbol) as \"tradeStockCount\" from quoteejb a where a.symbol like 's:%'");
-            rs = stmt.executeQuery();
-            rs.next();
-            int tradeStockCount = rs.getInt("tradeStockCount");
-            runStatsData.setTradeStockCount(tradeStockCount);
-            stmt.close();
-           
-
-			//Count of trade users login, logout
-            stmt = getStatement(conn, "select sum(loginCount) as \"sumLoginCount\", sum(logoutCount) as \"sumLogoutCount\" from accountejb a where  a.profile_userID like 'uid:%'");
-            rs = stmt.executeQuery();
-            rs.next();
-            int sumLoginCount  = rs.getInt("sumLoginCount");
-            int sumLogoutCount = rs.getInt("sumLogoutCount");
-            runStatsData.setSumLoginCount(sumLoginCount);
-            runStatsData.setSumLogoutCount(sumLogoutCount);            
-            stmt.close();
-            
-            rs.close();
-			//Update logoutcount and loginCount back to zero
-            
-            stmt = getStatement(conn, "update accountejb set logoutCount=0,loginCount=0 where profile_userID like 'uid:%'");
-            rowCount = stmt.executeUpdate();
-            stmt.close();
-
-			//count holdings for trade users
-            stmt = getStatement(conn, "select count(holdingid) as \"holdingCount\" from holdingejb h where h.account_accountid in "
-            							+ "(select accountid from accountejb a where a.profile_userid like 'uid:%')");
-            
-            rs = stmt.executeQuery();
-            rs.next();
+			stmt = getStatement(conn,
+					"delete from holdingejb where holdingejb.account_accountid is null");
+			int x = stmt.executeUpdate();
+			stmt.close();
+
+			// Count and Delete newly registered users (users w/ id that start
+            // "ru:%":
+			stmt = getStatement(conn,
+					"delete from accountprofileejb where userid like 'ru:%'");
+			int rowCount = stmt.executeUpdate();
+			stmt.close();
+
+			stmt = getStatement(
+					conn,
+					"delete from orderejb where account_accountid in (select accountid from accountejb a where a.profile_userid like 'ru:%')");
+			rowCount = stmt.executeUpdate();
+			stmt.close();
+
+			stmt = getStatement(
+					conn,
+					"delete from holdingejb where account_accountid in (select accountid from accountejb a where a.profile_userid like 'ru:%')");
+			rowCount = stmt.executeUpdate();
+			stmt.close();
+
+			stmt = getStatement(conn,
+					"delete from accountejb where profile_userid like 'ru:%'");
+			int newUserCount = stmt.executeUpdate();
+			runStatsData.setNewUserCount(newUserCount);
+			stmt.close();
+
+			// Count of trade users
+			stmt = getStatement(
+					conn,
+					"select count(accountid) as \"tradeUserCount\" from accountejb a where a.profile_userid like 'uid:%'");
+			rs = stmt.executeQuery();
+			rs.next();
+			int tradeUserCount = rs.getInt("tradeUserCount");
+			runStatsData.setTradeUserCount(tradeUserCount);
+			stmt.close();
+
+			rs.close();
+			// Count of trade stocks
+			stmt = getStatement(
+					conn,

[... 786 lines stripped ...]


Mime
View raw message