VIBE v5.1.6
Search Engine
|
Public Member Functions | |
DatabaseConnector () throws FileNotFoundException, IOException | |
DatabaseConnector (Path path) throws FileNotFoundException, IOException | |
void | createTables () throws SQLException |
Connection | getConnection () throws SQLException |
void | insertSearch (Connection db, String query) throws SQLException |
void | insertResults (Connection db, String uri) throws SQLException |
List< String > | getTopFiveSearches (Connection db) throws SQLException |
List< String > | getTopFiveResults (Connection db) throws SQLException |
void | resetMetaData (Connection db) throws SQLException |
Set< String > | getTables (Connection db) throws SQLException |
boolean | testConnection () |
Static Public Member Functions | |
static Properties | loadConfig (Path path) throws FileNotFoundException, IOException |
Public Attributes | |
final String | uri |
Static Public Attributes | |
static final String | INSERT |
static final String | GET_TOP_FIVE |
static final String | CREATE_TABLE |
This class is designed to test your database configuration. You need to have a database.properties file with username, password, database, and hostname. You must also have the tunnel to stargate.cs.usfca.edu running if you are off-campus.
edu.usfca.cs272.DatabaseConnector.DatabaseConnector | ( | ) | throws FileNotFoundException, IOException |
Creates a connector from a "database.properties" file located in the current working directory.
IOException | if unable to properly parse properties file |
FileNotFoundException | if properties file not found |
edu.usfca.cs272.DatabaseConnector.DatabaseConnector | ( | Path | path | ) | throws FileNotFoundException, IOException |
Creates a connector from the provided database properties file.
path | path to the database properties file |
IOException | if unable to properly parse properties file |
FileNotFoundException | if properties file not found |
void edu.usfca.cs272.DatabaseConnector.createTables | ( | ) | throws SQLException |
Creates the required sql tables if they do not already exist.
SQLException | if there is a problem connecting to the database. |
Connection edu.usfca.cs272.DatabaseConnector.getConnection | ( | ) | throws SQLException |
Attempts to connect to database using loaded configuration.
SQLException | if unable to establish database connection |
Set< String > edu.usfca.cs272.DatabaseConnector.getTables | ( | Connection | db | ) | throws SQLException |
Opens a database connection and returns a set of found tables. Will return an empty set if there are no results.
db | the active database connection |
SQLException | if unable to execute SQL |
List< String > edu.usfca.cs272.DatabaseConnector.getTopFiveResults | ( | Connection | db | ) | throws SQLException |
Executes the GET_TOP_FIVE query to get the 5 most visited results.
db | the active database connection. |
SQLException | if unable to execute the query.s |
List< String > edu.usfca.cs272.DatabaseConnector.getTopFiveSearches | ( | Connection | db | ) | throws SQLException |
Executes the GET_TOP_FIVE query to get the 5 most searched queries.
db | The active database connection |
SQLException | if unable to execute the query. |
void edu.usfca.cs272.DatabaseConnector.insertResults | ( | Connection | db, |
String | uri ) throws SQLException |
Executes INSERT for the results table.
db | the database connection |
uri | the uri to store. |
SQLException | if unable to execute the query. |
void edu.usfca.cs272.DatabaseConnector.insertSearch | ( | Connection | db, |
String | query ) throws SQLException |
Executes the INSERT for the queries table..
db | The active database connection |
query | the query that has been searched. |
SQLException | if unable to execute the query. |
|
static |
Attempts to load properties file with database configuration. Must include username, password, database, and hostname.
path | path to database properties file |
IOException | if unable to properly parse properties file |
FileNotFoundException | if properties file not found |
void edu.usfca.cs272.DatabaseConnector.resetMetaData | ( | Connection | db | ) | throws SQLException |
deletes everything from the queries table.
db | The active database connection |
SQLException | if unable to execute the query. |
boolean edu.usfca.cs272.DatabaseConnector.testConnection | ( | ) |
Opens a database connection, executes a simple statement, and closes the database connection.
|
static |
|
static |
SQL query to get the top 5 queries searched in the server.
|
static |
SQL query to insert into the queries table every time a query is called in the server. if a query is seen for the first time, the count is set to 1 if a query has already been seen, the count is incremented.
final String edu.usfca.cs272.DatabaseConnector.uri |
URI to use when connecting to database. Should be in the format: jdbc:subprotocol://hostname/database