public class DatabaseActions
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.String[]> |
apTable
Map that stores the necessary data from all discovered access points.
|
private com.mysql.jdbc.Connection |
con
Connection variable for connecting to the database.
|
private java.util.Map<java.lang.String,java.lang.String[]> |
conIfTable
Map that stores the necessary data from all devices' connected interfaces.
|
private java.util.Map<java.lang.String,java.lang.String[]> |
conWifTable
Map that stores the necessary data from all devices' connected wireless interfaces.
|
private java.util.Map<java.lang.String,java.lang.String> |
devapTable
Map that stores the signal level from all devices' discovered access points.
|
private java.util.Map<java.lang.String,java.lang.Long> |
devtimesTable
Map that stores the latest update times from all devices.
|
private java.util.Map<java.lang.String,java.lang.String> |
discIfTable
Map that stores the necessary data from all devices' disconnected interfaces.
|
private java.util.Map<java.lang.String,java.lang.String[]> |
discWifTable
Map that stores the necessary data from all devices' disconnected wireless interfaces.
|
private static DatabaseActions |
instance
The private instance of this singleton class.
|
private java.util.Map<java.lang.String,java.lang.String> |
localTable
Map that stores the current bit rate from all devices' local loopbacks.
|
private java.lang.String |
password
Password for the connection to the database.
|
private java.sql.PreparedStatement |
pst
PreparedStatement variable for making prepared statements to the database.
|
private java.sql.ResultSet |
rs
ResultSet variable for taking the results from a query to the database.
|
private java.sql.Statement |
st
Statement variable for making statements to the database.
|
private java.lang.String |
url
URL for the connection to the database.
|
private java.lang.String |
user
Username for the connection to the database.
|
Modifier | Constructor and Description |
---|---|
private |
DatabaseActions()
Private constructor for the singleton class that makes the connection to the db
and then checks and prints the version of mysql, deletes previously created tables
and creates the necessary tables in the database.
|
Modifier and Type | Method and Description |
---|---|
private void |
checkVersion()
Checks the version of the database and prints it to the terminal.
|
java.lang.Object |
clone() |
private void |
closeConection()
Closes the connection between the program and the database.
|
private void |
createTables()
Creates the necessary tables to the database for the program.
|
void |
deleteAccessPoint(java.lang.String device,
java.lang.String mac)
Deletes the access point for the device from the database
|
private void |
deleteDevice(java.lang.String device)
Deletes all the collected data of the device from the database and the middle memory.
|
void |
deleteInterface(java.lang.String device,
java.lang.String ifname)
Deletes from the database the requested interface for the device.
|
private void |
deleteTables() |
void |
deleteWireless(java.lang.String device,
java.lang.String wifname)
Deletes from the database the requested wireless interface for the device.
|
java.util.List<java.lang.String[]> |
getAccessPointsData(java.lang.String device)
Gets from the middle memory the available access points and their data for the device.
|
static DatabaseActions |
getInstance()
Creates the unique object of this class if not created.
|
java.util.Vector<java.lang.String> |
getInterfaceData(java.lang.String device,
java.lang.String ifname)
Gets from the middle memory the requested interface data for the device.
|
java.util.Vector<java.lang.String> |
getInterfaces(java.lang.String device)
Checks the database for the available interfaces for this device.
|
java.util.Vector<java.lang.String> |
getWireless(java.lang.String device)
Checks the database for the available wireless interfaces for this device.
|
java.util.Vector<java.lang.String> |
getWirelessData(java.lang.String device,
java.lang.String wifname)
Gets from the middle memory the requested wireless interface data for the device.
|
void |
insertData(java.lang.String device,
MonitorData MD)
Gets the data sent by the device and do the necessary actions to store them to the database
and the middle memory, and refreshes the gui if necessary.
|
void |
run() |
private void |
showTables()
Finds the created tables in the current database and prints them.
|
private void |
updateData(java.lang.String tableName,
java.lang.String dbElemName,
java.lang.String elem,
java.lang.String device,
java.lang.String name) |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
private static DatabaseActions instance
private final java.lang.String url
private final java.lang.String user
private final java.lang.String password
private com.mysql.jdbc.Connection con
private java.sql.Statement st
private java.sql.PreparedStatement pst
private java.sql.ResultSet rs
private volatile java.util.Map<java.lang.String,java.lang.String> localTable
private volatile java.util.Map<java.lang.String,java.lang.String> discIfTable
private volatile java.util.Map<java.lang.String,java.lang.String[]> conIfTable
private volatile java.util.Map<java.lang.String,java.lang.String[]> discWifTable
private volatile java.util.Map<java.lang.String,java.lang.String[]> conWifTable
private volatile java.util.Map<java.lang.String,java.lang.String[]> apTable
private volatile java.util.Map<java.lang.String,java.lang.String> devapTable
private volatile java.util.Map<java.lang.String,java.lang.Long> devtimesTable
private DatabaseActions()
public static DatabaseActions getInstance()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Thread
java.lang.CloneNotSupportedException
private void checkVersion()
private void createTables()
public void insertData(java.lang.String device, MonitorData MD)
device
- The name of the device that sent the dataMD
- MonitorData object with all the data sent by the deviceprivate void updateData(java.lang.String tableName, java.lang.String dbElemName, java.lang.String elem, java.lang.String device, java.lang.String name)
public java.util.Vector<java.lang.String> getInterfaces(java.lang.String device)
device
- The name of the device that we want to check its interfacespublic java.util.Vector<java.lang.String> getInterfaceData(java.lang.String device, java.lang.String ifname)
device
- The name of the device that we want to get the interface dataifname
- The name of the interface we want to get data frompublic void deleteInterface(java.lang.String device, java.lang.String ifname)
device
- The name of the device that the interface belongsifname
- The name of the interface we want to deletepublic java.util.Vector<java.lang.String> getWireless(java.lang.String device)
device
- The name of the device that we want to check its wireless interfacespublic java.util.Vector<java.lang.String> getWirelessData(java.lang.String device, java.lang.String wifname)
device
- The name of the device that we want to get the wireless interface datawifname
- The name of the wireless interface we want to get data frompublic void deleteWireless(java.lang.String device, java.lang.String wifname)
device
- The name of the device that the wireless interface belongswifname
- The name of the wireless interface we want to deletepublic java.util.List<java.lang.String[]> getAccessPointsData(java.lang.String device)
device
- The name of the device we want to get the discovered access pointspublic void deleteAccessPoint(java.lang.String device, java.lang.String mac)
device
- The name of the device we want to delete the access point frommac
- The mac address of the access point we want to deleteprivate void deleteDevice(java.lang.String device)
device
- The name of the device we want to deleteprivate void deleteTables()
private void showTables()
private void closeConection()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread