Package tenapull.util
Class Database
java.lang.Object
tenapull.util.Database
public class Database
extends java.lang.Object
Provides access to the database
Created on 8/31/16.
3/10/22 WJA -- changed from singleton class to static (no instance) utility class
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDB_HARD_RESETThe name of the sql script which performs a full reset of the database -
Method Summary
Modifier and Type Method Description static voidconnect()Connect.static voiddisconnect()Disconnect.static java.sql.ConnectiongetConnection()Gets connection.static voidhardReset()Reset the databasestatic voidreset()Reset the databasestatic voidrunSQL(java.lang.String sqlFile)Run the sql.
-
Field Details
-
DB_HARD_RESET
public static final java.lang.String DB_HARD_RESETThe name of the sql script which performs a full reset of the database- See Also:
- Constant Field Values
-
-
Method Details
-
getConnection
public static java.sql.Connection getConnection()Gets connection.- Returns:
- the connection
-
connect
public static void connect() throws java.lang.ExceptionConnect.- Throws:
java.lang.Exception- the exception
-
disconnect
public static void disconnect()Disconnect. -
runSQL
public static void runSQL(java.lang.String sqlFile) throws java.io.FileNotFoundExceptionRun the sql.- Parameters:
sqlFile- the sql file to be read and executed line by line- Throws:
java.io.FileNotFoundException- the file not found exception
-
reset
public static void reset() throws java.io.FileNotFoundExceptionReset the database- Throws:
java.io.FileNotFoundException- if the hard reset sql script can't be found
-
hardReset
public static void hardReset() throws java.io.FileNotFoundExceptionReset the database- Throws:
java.io.FileNotFoundException- if the hard reset sql script can't be found
-