Class NeqSimDataBase
java.lang.Object
neqsim.util.database.NeqSimDataBase
- All Implemented Interfaces:
Serializable, AutoCloseable, FileSystemSettings
- Direct Known Subclasses:
NeqSimContractDataBase, NeqSimProcessDesignDataBase
public class NeqSimDataBase
extends Object
implements FileSystemSettings, Serializable, AutoCloseable
NeqSimDataBase class.
- Version:
- Dec 2018
- Author:
- Even Solbraa
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Stringprivate static booleanprotected Connectionstatic StringConstantdataBasePath="".private static Stringprivate static booleanTrue while h2 database is being initialized.private static booleanTrue if h2 database has been initialized, i.e., populated with tables(package private) static org.apache.logging.log4j.LoggerLogger object for class.private static Stringprivate static final longSerialization version UID.private Statementprivate static StringFields inherited from interface FileSystemSettings
defaultDatabaseRootRoot, defaultFileTreeRoot, fileExtension, relativeFilePath, root, tempDir -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static booleancreateTemporaryTables.booleanExecute query using execute.voidexecuteQuery(String sqlString) Execute query using executeQuery but do not return anything.static String[]getComponentNames.getConnection.static StringGetter for the fieldconnectionString.static StringGetter for the fielddataBaseType.getResultSet(String sqlString) Execute query using executeQuery and return ResultSet.Getter for the fieldstatement.static booleanhasComponent(String name) Verify if database has a component.static booleanhasTempComponent(String name) Verify if database has a component.static voidinitH2DatabaseFromCSVfiles.openConnection.static voidreplaceTable(String tableName, String path) Drops and re-creates table from contents in csv file.static voidsetConnectionString(String aConnectionString) Setter for the fieldconnectionString.static voidsetCreateTemporaryTables(boolean createTemporaryTables) Setter for the fieldcreateTemporaryTables.static voidsetDataBaseType(String aDataBaseType) Setter for the fielddataBaseType.static voidsetDataBaseType(String aDataBaseType, String connectionString) Setter for the fielddataBaseType.static voidsetPassword(String aPassword) Setter for the fieldpassword.voidsetStatement(Statement statement) Setter for the fieldstatement.static voidsetUsername(String aUsername) Setter for the fieldusername.static voidupdateTable(String tableName) Drops and re-creates table from contents in default csv file.static voidupdateTable(String tableName, String path) Drops and re-creates table from contents in csv file.static voiduseExtendedComponentDatabase(boolean useExtendedDatabase) Use extended component database.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
logger
static org.apache.logging.log4j.Logger loggerLogger object for class. -
dataBasePath
ConstantdataBasePath="". -
createTemporaryTables
private static boolean createTemporaryTables -
username
-
password
-
dataBaseType
-
connectionString
-
h2IsInitialized
private static boolean h2IsInitializedTrue if h2 database has been initialized, i.e., populated with tables -
h2IsInitalizing
private static boolean h2IsInitalizingTrue while h2 database is being initialized. -
statement
-
databaseConnection
-
-
Constructor Details
-
NeqSimDataBase
public NeqSimDataBase()Constructor for NeqSimDataBase.
-
-
Method Details
-
openConnection
openConnection.
- Returns:
- a Connection object
- Throws:
SQLException- if any.ClassNotFoundException- if any.
-
getConnection
-
getStatement
-
setStatement
Setter for the field
statement.- Parameters:
statement- a Statement object
-
execute
Execute query using execute.
- Parameters:
sqlString- Query to execute.- Returns:
- True if the first result is a ResultSet object; false if it is an update count or there are no results
-
executeQuery
Execute query using executeQuery but do not return anything.
- Parameters:
sqlString- Query to execute.
-
getResultSet
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
SQLException
-
createTemporaryTables
public static boolean createTemporaryTables()createTemporaryTables.
- Returns:
- the createTemporaryTables
-
setCreateTemporaryTables
public static void setCreateTemporaryTables(boolean createTemporaryTables) Setter for the field
createTemporaryTables.- Parameters:
createTemporaryTables- the createTemporaryTables to set
-
getDataBaseType
-
setDataBaseType
-
setDataBaseType
-
setUsername
Setter for the field
username.- Parameters:
aUsername- the username to set
-
setPassword
Setter for the field
password.- Parameters:
aPassword- the password to set
-
getConnectionString
Getter for the field
connectionString.- Returns:
- the connectionString
-
setConnectionString
Setter for the field
connectionString.- Parameters:
aConnectionString- the connectionString to set
-
getComponentNames
-
hasComponent
Verify if database has a component.- Parameters:
name- Name of component to look for.- Returns:
- True if component is found.
-
hasTempComponent
Verify if database has a component.- Parameters:
name- Name of component to look for.- Returns:
- True if component is found.
-
updateTable
Drops and re-creates table from contents in default csv file.- Parameters:
tableName- Name of table to replace
-
useExtendedComponentDatabase
public static void useExtendedComponentDatabase(boolean useExtendedDatabase) Use extended component database.- Parameters:
useExtendedDatabase- the use extended database
-
updateTable
-
replaceTable
-
initH2DatabaseFromCSVfiles
public static void initH2DatabaseFromCSVfiles()initH2DatabaseFromCSVfiles.
-