|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectdb.DBUtils
Contains methods to initiate user queries. Queries or calls to methods that generate standard queries are invoked and this class interfaces with the actual data access engine to run these queries against the database.
| Field Summary | |
private static java.util.ArrayList |
batchQueries
collection queries which are sent to the database to process as a batch when its size reaches a certain level |
| Constructor Summary | |
DBUtils()
|
|
| Method Summary | |
static void |
clearBatchQueries()
Initializes the bach Queries array list to begin accepting new update queries |
static boolean |
constructInsertQuery(java.util.HashMap values,
boolean lastUpdate)
Constructs an insert query for the values passed in via the hashmap |
static void |
constructUpdateQuery(java.util.HashMap values,
boolean lastUpdate)
Constructs an update query for the values passed in via the hashmap |
private static java.lang.String |
convertQueryToXML(java.lang.String query)
Converts the standard string query into an XML wrapped query |
static boolean |
dropStockStatTable()
Drops all items in the stock stat table in preperation for adding new statistics values |
static void |
executeBatch()
Sends off a batch query request in a threaded manner and returns and clears the arraylist batchQueries to get ready for the next batch of queries to be created. |
private static void |
executeMiniBatch(java.util.ArrayList miniBatch)
Executes a batch of queries created inside the DBUtils class. |
static java.lang.Object |
getDataSetForTicker(java.lang.String ticker)
Gets the results set for an individual ticker name. |
static java.lang.Object |
getDbDesc()
Runs a description query to retrieve a description of the stockStat table |
static java.lang.Object |
getStatisticsList()
Gets an unaltered result set encapsulating the list of all stocks that have statistics associated with them |
static java.lang.Object |
getStockList()
Gets an unaltered result set encapsulating the list of all stocks in the database |
static java.lang.Object |
getTestStockList()
Gets an unaltered test result set encapsulating the list of one stock in the database - AAUK |
static jqubeObjects.DataSet |
runDateQuery(jqubeObjects.UserQuery q)
Run a date range query to receive a date range data set to plot and put in the results set table model |
static jqubeObjects.DataSet |
runInitializeQuery()
Runs the initial query that is returns results to populate the table on the main panel containing the entire list of stocks and company name |
static jqubeObjects.DataSet |
runNewsQuery(jqubeObjects.UserQuery q)
Run a news query to receive every news story available for the ticker withing the specified date range |
static jqubeObjects.DataSet |
runQuery(java.lang.String query)
Takes the user query and passes it to the functions to handle connecting to and executing the query |
static jqubeObjects.DataSet |
runStockQuery(jqubeObjects.UserQuery q)
Construct, send and retrieve results for a single user query encapsulated in the query object |
static java.lang.Object |
runStockStatQuery()
Runs a query to retrieve the stock statistics for every stock in the database |
static boolean |
runTestQuery(java.lang.String connectionString)
Run a test query to test the connectivity to the database. |
static void |
updateMarketInStatTable()
Re-associates the market with each ticker in the stock stat table after all statistic insert statemts have been run. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private static java.util.ArrayList batchQueries
| Constructor Detail |
public DBUtils()
| Method Detail |
private static java.lang.String convertQueryToXML(java.lang.String query)
query - Regular string query
public static jqubeObjects.DataSet runQuery(java.lang.String query)
query - The XML wrapped query to pass to the database
public static boolean runTestQuery(java.lang.String connectionString)
The passed in connectionString can either be a valid string or null, in which case the default connection string set in the DBConnect class is used to attempt to form the connection.
public static jqubeObjects.DataSet runInitializeQuery()
public static jqubeObjects.DataSet runStockQuery(jqubeObjects.UserQuery q)
q - User Query object that defines a query
public static jqubeObjects.DataSet runDateQuery(jqubeObjects.UserQuery q)
q - User query object specifying the start and end date of the date range query
public static jqubeObjects.DataSet runNewsQuery(jqubeObjects.UserQuery q)
q - User query object specifying the ticker, start and end date of the news query
public static java.lang.Object getStockList()
public static java.lang.Object getStatisticsList()
public static java.lang.Object getTestStockList()
public static java.lang.Object getDataSetForTicker(java.lang.String ticker)
Runs the query:
SELECT ticker, open, close, high, low, volume, date, date_format(date,'%c') month, date_format(date,'%Y') year
FROM stock
WHERE ticker = 'ticker'
ORDER BY date ASC
ticker - the ticker to query for
public static void clearBatchQueries()
public static void constructUpdateQuery(java.util.HashMap values,
boolean lastUpdate)
values - hashmap of values to update the stockstat table withlastUpdate - true if this is the last update statistic to be loaded to the database
public static boolean constructInsertQuery(java.util.HashMap values,
boolean lastUpdate)
values - hashmap of values to insert into the stockstat tablelastUpdate - true if this is the last insert statistic to be loaded to the database
public static java.lang.Object runStockStatQuery()
public static boolean dropStockStatTable()
public static void updateMarketInStatTable()
Runs the update queries as a batch set.
public static java.lang.Object getDbDesc()
public static void executeBatch()
private static void executeMiniBatch(java.util.ArrayList miniBatch)
This gets around the problem of other major batch threads deleting a small set of batch queries that have not been invoked yet.
miniBatch - the collection of queries to run in batch mode
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||