Class Database.Settings
- java.lang.Object
-
- com.jgcomptech.tools.databasetools.jdbc.Database.Settings
-
- Enclosing class:
- Database
public static final class Database.Settings extends java.lang.Object
Allows setting and retrieval of settings values from a database, useDatabase.getSettings()
to access methods.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
createTable()
Creates a Settings table in the specified database.boolean
exists(java.lang.String settingName)
Checks if a setting exists in the settings table.java.util.HashMap<java.lang.String,java.lang.String>
getSettingsList()
Returns a list of all settings in the Settings table in the specified database.java.lang.String
getValue(java.lang.String settingName)
Returns a setting from the settings table, if setting doesn't exist, returns an empty string.boolean
setValue(java.lang.String settingName, java.lang.String settingValue)
Sets a setting in the settings table, if setting doesn't exist, it is created.
-
-
-
Method Detail
-
createTable
public boolean createTable() throws java.sql.SQLException
Creates a Settings table in the specified database.- Returns:
- false if the table already exists
- Throws:
java.sql.SQLException
- if error occurs during table creation
-
getSettingsList
public java.util.HashMap<java.lang.String,java.lang.String> getSettingsList() throws java.sql.SQLException
Returns a list of all settings in the Settings table in the specified database.- Returns:
- a list of all settings in the Settings table as a HashMap
- Throws:
java.sql.SQLException
- if error occurs during query
-
getValue
public java.lang.String getValue(java.lang.String settingName) throws java.sql.SQLException
Returns a setting from the settings table, if setting doesn't exist, returns an empty string.- Parameters:
settingName
- name of the setting to return a value- Returns:
- value of the specified setting
- Throws:
java.sql.SQLException
- if error occurs during lookup
-
setValue
public boolean setValue(java.lang.String settingName, java.lang.String settingValue) throws java.sql.SQLException
Sets a setting in the settings table, if setting doesn't exist, it is created.- Parameters:
settingName
- name of the setting to set its valuesettingValue
- value to set- Returns:
- true if setting is set successfully
- Throws:
java.sql.SQLException
- if error occurs during lookup
-
exists
public boolean exists(java.lang.String settingName) throws java.sql.SQLException
Checks if a setting exists in the settings table.- Parameters:
settingName
- setting to check for- Returns:
- true if setting exists
- Throws:
java.lang.IllegalStateException
- if a setting is defined multiple timesjava.sql.SQLException
- if error occurs during lookup
-
-