Listing 1

StringBuilder sql = new StringBuilder ( );
Date timestamp = new Date ( o.timestamp );
// for the UpdateTimestamp column.

sql.append ( "UPDATE orders SET FilledQty=" );
sql.append ( order.fillQty );
sql.append ( ", OrderStatus = '" );
sql.append ( order.orderStatus );
sql.append ( "', UpdateTimestamp=" );
sql.append ( timestamp );
sql.append ( "WHERE OrderID = '" );
sql.append ( order.orderId );
sql.append ( "'" );

/* For example this might create 
UPDATE Orders SET FilledQty=500, 
OrderStatus='Partial Fill', 
UpdateTimestamp='2006-06-06 12:30:02'
WHERE OrderID = '123456'; */

Statement st = c.createStatement ( ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY );
st.executeQuery ( sql.toString() );

Listing 2

Properties conxProps = new Properties ( );
// Use whatever database-specific parameters are required here.
conxProps.setProperty ( "endpoints", "server1=localhost:30303" );
c = initJDBCConnection ( conxProps );

// Initialize the Data by creating the necessary tables.  If they already exist,
// DataPublisherHelper deletes their contents instead.
DataPublisherHelper.createOrdersTable ( c );
DataPublisherHelper.createQuotesTable ( c );

// Initialize orders.  The SimpleOrderGenerator will create a large basket of
// orders.  We receive a onNewOrder() callback for each one.
orderGenerator.initOrders();

// Start streaming quotes and order fill notifications
orderGenerator.start();
quoteGenerator.start();

Listing 3

	quick.dbtable.DBTable dBTable1 = null;
java.sql.ResultSet resultSet;

// SQL select to fetch all orders and corresponding quotes for select financial instruments
static String quotesSql = "SELECT o.Symbol, o.Client, o.Side, o.Quantity, o.OrderType, o.FilledQty, o.OrderID,
 o.ClientComment, q.Bid, " +
	    "q.Ask, " +
	    "q.AskSize, " +
	    "q.BidSize, " + 
	    "q.UpdateTimestamp " +
	    "FROM quotes q, orders o WHERE q.Symbol = o.Symbol " + 
    " AND o.Symbol IN ('IBM', 'INTC', 'AMD', 'MOT')";
// NOTE: The "IN clause" above is typically dynamically configured based on user choice; There will be numerous such
 views that are concurrently monitored by the user
// Initialize the GUI table and start the monitor thread
	 public void initOrderQuoteTable() throws Exception {
	  {
	    // set Frame properties
	    setSize(1280,1024);
	    setVisible(true);

	    //create a new quicktable
	    dBTable1 = new DBTable();

	    //add to frame
	    getContentPane().add(dBTable1);

	    // to create the navigation bars for the table
	    dBTable1.createControlPanel();

	    // Start the polling thread to refresh the OrderQuoteTable
	    startPollingThread();

    .....

	  }

public void startPollingThread() throws Exception {
Thread pollingThread = new Thread( new Runnable() {
public void run() {
 // < Execute the query on DB and obtain instance of java.sql.ResultSet
 //Refresh the Jtable
 synchronized ( resultSet ) { dBTable1.refresh ( resultSet); }
  pollingThread.sleep (configuredTimeInterval);
 }
		} );
pollingThread.start();
}

Listing 4

// Do the following instead of polling the DB .... Replace startPollingThread above
// Acquire connection of the JMS provider service, start a non-transactional session on the DB events queue, create a
 receiver on the queue and set the listener to receive the events asynchronously.

queueConnectionFactory = jndiLookup();
queueConnection = queueConnectionFactory.createQueueConnection();

queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queue = jndiLookup(queueName);

// Use JMS message selector to limit events routed to Jtable client process
// Note that 'symbol' would have to be explicitly set as a JMS header property when message
// is constructed
String selector = "symbol IN ('IBM', 'INTC', 'AMD', 'MOT')";
queueReceiver = queueSession.createReceiver(queue, selector);

dbEventListener = new DBEventListener();
queueReceiver.setMessageListener(dbEventListener);
queueConnection.start();
 


// Implement the DBEventListener; Implements javax.jms.MessageListener interface
public class DBEventListener implements MessageListener {

    public void onMessage(Message message) {
      try {
< Execute the query on DB and obtain instance of java.sql.ResultSet
 //Refresh the Jtable
 	synchronized ( resultSet ) { dBTable1.refresh ( resultSet); };
            } catch (JMSException e) {
                ;
            }
        }
    }

Listing 5

// The SQL we'll use as a Continuous Query
String CQSql = "SELECT * FROM Orders, Quotes WHERE Quotes.Symbol=Orders.Symbol";

// Create a new QuickTable for visual display of our JDBC ResultSet
dBTable1 = new DBTable();

// Add the QuickTable to the Swing frame
frame.getContentPane().add(dBTable1);

// Connect to the Real Time Events engine (essentially the same as any JDBC connection)
Properties conxProps = new Properties();
conxProps.setProperty ( "endpoints", "server1=localhost:30303" );
c = initCQEngineConnection ( conxProps );

// Note that CQManager is specific to the the GemFire RTE CQ implementation
// Create a CQManager for the Connection
cqManager = CQManager.getCQManager ( c );

// Create an register the continuous query using the CQManager and our SQL String.
CQ exampleCQ = cqManager.create ( CQSql );
ResultSet rs = exampleCQ.register ( "exampleCQ", CQSql );

// Populate the GUI QuickTable with the Result Set returned by the CQ initialization.
 dBTable1.refresh ( rs );

// Once the table has been initialized with data, start listening for CQ Updates  .
exampleCQ.setCQListener ( this );