Class DatabaseModel
- java.lang.Object
-
- org.teichert.databaseexplorer.database.DatabaseModel
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
H2SQLModel
,InformixSQLModel
,MariaDBModel
,MSSQLModel
,MySQLModel
,PostgreSQLModel
,SQLiteModel
public abstract class DatabaseModel extends Object implements Serializable
Base-Class of all database-types.
This class is the procides all methods to access to a database and load any information and more.
Most of the methods are abstract so that all database-variants has to implement their own implementations.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static long
serialVersionUID
List<SQLDataType>
types
-
Constructor Summary
Constructors Modifier Constructor Description protected
DatabaseModel()
-
Method Summary
-
-
-
Field Detail
-
serialVersionUID
public static final long serialVersionUID
- See Also:
- Constant Field Values
-
types
public List<SQLDataType> types
-
-
Method Detail
-
initTypes
protected abstract void initTypes()
-
getDriver
public abstract String getDriver()
-
getDialect
public abstract String getDialect()
-
executeSQL
public abstract Exception executeSQL(int connectionPoolId, SQLDatabase database, String sql, SQLTextEditor<?> editor, IDoingAfterThread d) throws Exception
- Throws:
Exception
-
executePreparedSQL
public abstract Exception executePreparedSQL(int connectionPoolId, SQLDatabase database, String sql, Object... values) throws Exception
- Throws:
Exception
-
executeSQL_SELECT
public abstract KeyValue<String,SQLTable> executeSQL_SELECT(int connectionPoolId, SQLTextEditor<?> editor, SQLTable table, int limit, Map<Object,Object> mapOfData) throws SQLException
- Throws:
SQLException
-
executeSQL_SELECT
public abstract KeyValue<String,SQLTable> executeSQL_SELECT(int connectionPoolId, SQLTextEditor<?> editor, SQLDatabase db, String sql, int limit, Map<Object,Object> mapOfData) throws SQLException
- Throws:
SQLException
-
executePreparedSQL_SELECT
public abstract KeyValue<String,SQLTable> executePreparedSQL_SELECT(int connectionPoolId, SQLDatabase database, String sql, Object... values) throws SQLException
- Throws:
SQLException
-
reloadTable
public abstract void reloadTable(int connectionPoolId, SQLTable table, int limit) throws Exception
- Throws:
Exception
-
loadSQLDatabase
public abstract SQLDatabase loadSQLDatabase(String id, String grouping, String customName, String sshConnId, String sshForwardingId, String user, String pwd, String ip, String port, String databaseName, String parameter, boolean isLazyLoaded, Class<? extends DatabaseModel> databaseClass, Map<String,Object> map) throws InstantiationException, IllegalAccessException, SQLException
-
getConnectionString
public abstract String getConnectionString(String db, String ip, String port, String parameter)
-
getConnectionStringQuerys
public abstract String getConnectionStringQuerys()
-
createLimitSQL
public abstract StringBuilder createLimitSQL(String sql, int limit, StringBuilder b)
-
updateTableValue
public abstract void updateTableValue(SQLTableColumn column, SQLTableValue[] oldValues, SQLTableValue newValue) throws Exception
- Throws:
Exception
-
renameTable
public abstract void renameTable(SQLTable oldTable, SQLTable newTable, IDoingAfterThread d) throws Exception
- Throws:
Exception
-
addTableColumn
public abstract void addTableColumn(SQLTable table, SQLTableColumn newColumn, Object defaultValue, IDoingAfterThread d) throws Exception
- Throws:
Exception
-
renameTableColumn
public abstract void renameTableColumn(SQLTableColumn oldColumn, SQLTableColumn newColumn, IDoingAfterThread d) throws Exception
- Throws:
Exception
-
modifyTableColumn
public abstract void modifyTableColumn(SQLTableColumn column, IDoingAfterThread d) throws Exception
- Throws:
Exception
-
createForeignKey
public abstract Exception createForeignKey(SQLForeignInfo foreignInfo, String addition) throws Exception
- Throws:
Exception
-
deleteTableValue
public abstract void deleteTableValue(SQLTableValue[] oldValues) throws Exception
- Throws:
Exception
-
dropColumn
public abstract void dropColumn(SQLTableColumn column, SQLTextEditor<?> editor, IDoingAfterThread d) throws Exception
- Throws:
Exception
-
dropIndex
public abstract void dropIndex(SQLIndex index, IDoingAfterThread d) throws Exception
- Throws:
Exception
-
insertNewTableValue
public abstract void insertNewTableValue(String columnName, SQLTableValue newValue) throws SQLException
- Throws:
SQLException
-
copyRows
public abstract void copyRows(DatabaseModel model, SQLTable from, SQLTable to) throws Exception
- Throws:
Exception
-
createNewSQLTable
public abstract void createNewSQLTable(SQLTable table) throws SQLException
- Throws:
SQLException
-
createNewSQLIndexes
public abstract void createNewSQLIndexes(SQLTable table) throws SQLException
- Throws:
SQLException
-
convertObject
public abstract Object convertObject(SQLTableColumn column, Object value)
-
convertSQLTableColumns
public abstract SQLTableColumn convertSQLTableColumns(SQLTableColumn column)
-
translateDataTypeString
public abstract SQLDataType translateDataTypeString(String columnType)
-
export
public abstract String export(String sql, SQLDatabase db) throws Exception
- Throws:
Exception
-
getSelectUserQuery
public abstract String getSelectUserQuery()
-
getAddForeignKeyString
public abstract String getAddForeignKeyString(SQLForeignInfo foreignInfo, String addition)
-
getDropColumnString
public abstract String getDropColumnString(SQLTableColumn column)
-
getModifyTableColumnString
public abstract String getModifyTableColumnString(SQLTableColumn column)
-
getRenameTableColumnString
public abstract String getRenameTableColumnString(SQLTableColumn oldColumn, SQLTableColumn newColumn)
-
getAddTableColumnString
public abstract String getAddTableColumnString(SQLTableColumn newColumn, Object defaultValue)
-
getRenameTableString
public abstract String getRenameTableString(SQLTable oldTable, SQLTable newTable)
-
getColumnFullname
public abstract String getColumnFullname(SQLTableColumn column)
-
getColumnNameForConversion
public abstract String getColumnNameForConversion(SQLTableColumn column)
-
needSize
public abstract boolean needSize(SQLDataType dataType)
-
getForeignKeyConstraintCheckString
public abstract String getForeignKeyConstraintCheckString(boolean disabling)
-
getTransactionStartEndString
public abstract String getTransactionStartEndString(boolean start)
-
getLoadSQLTriggersSQL
public abstract String getLoadSQLTriggersSQL(SQLTable table, String aliasTrgId, String aliasTrgCondition, String aliasTrgName, String aliasTrgEvent, String aliasTrgContent, String aliasTrgType)
-
getName
public String getName()
-
setName
public DatabaseModel setName(String name)
-
executeInternalSQL
public Exception executeInternalSQL(SQLDatabase database, String sql, SQLTextEditor<?> editor, IDoingAfterThread d)
-
dropDatabase
public void dropDatabase(SQLDatabase database, SQLTextEditor<?> editor, IDoingAfterThread d) throws Exception
- Throws:
Exception
-
dropTable
public void dropTable(SQLTable table, SQLTextEditor<?> editor, IDoingAfterThread d) throws Exception
- Throws:
Exception
-
getDropDatabaseString
public String getDropDatabaseString(SQLDatabase database)
-
createWhere
public String createWhere(List<SQLTableColumn> columns, SQLTableValue[] line)
Creates the where clause with the given columns and the line which should be selected!- Parameters:
columns
- = columns of the table in which to searchline
- = line values to search for.- Returns:
-
getValueByColumn
public SQLTableValue getValueByColumn(SQLTableColumn column, SQLTableValue[] values)
-
getInsertIntoString
public String getInsertIntoString(String columnName, SQLTableValue newValue)
-
getInsertIntoString
public String getInsertIntoString(SQLTableValue[] newValues, boolean withSimicolon)
-
getInsertIntoString
public String getInsertIntoString(String columnName, SQLTable table, SQLTableValue newValue)
-
createConnection
public Connection createConnection(String url, String user, String password) throws SQLException
- Throws:
SQLException
-
getInternalSystemDatabaseName
public String getInternalSystemDatabaseName()
Returns the name for another (internal) system database for getting Trigger information.
For Example, for MySQL and MariaDB it would be the database "INFORMATION_SCHEMA".
If the the trigger-information-table is in the same database, we has to return null.
has to be overwritten in the child class if it deviates!- Returns:
-
getCreateIndexString
public String getCreateIndexString(SQLTable table, String indexName, boolean nonUnique, boolean withSchema, String... columns)
Returns the string for creating a index with the given values.- Parameters:
table
-indexName
-nonUnique
-withSchema
-columns
-- Returns:
-
-