- java.lang.Object
-
- com.aoindustries.aoserv.client.AOServObject<K,T>
-
- com.aoindustries.aoserv.client.CachedObject<Integer,V>
-
- com.aoindustries.aoserv.client.CachedObjectIntegerKey<Database>
-
- com.aoindustries.aoserv.client.mysql.Database
-
- All Implemented Interfaces:
Streamable,StreamReadable,StreamWritable,Row,AOServReadable,AOServStreamable,AOServWritable,Dumpable,JdbcProvider,Removable,SingleTableObject<Integer,Database>
public final class Database extends CachedObjectIntegerKey<Database> implements Removable, Dumpable, JdbcProvider
AMySQLDatabasecorresponds to a unique MySQL table space on one server. The database name must be unique per server and, to aid in account portability, will typically be unique across the entire system.- Author:
- AO Industries, Inc.
- See Also:
DatabaseUser
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDatabase.CheckTableResultstatic classDatabase.Enginestatic classDatabase.NameRepresents a name that may be used for aDatabase.static classDatabase.TableStatus
-
Field Summary
Fields Modifier and Type Field Description static StringCENTOS_7_JDBC_DOCUMENTATION_URLThe URL for MySQL JDBC documentation.static StringCENTOS_7_JDBC_DRIVERThe classname of the JDBC driver used for theMySQLDatabase.static StringCENTOS_JDBC_DOCUMENTATION_URLThe URL for MySQL JDBC documentation.static StringCENTOS_JDBC_DRIVERThe classname of the JDBC driver used for theMySQLDatabase.static CharsetDUMP_ENCODINGThe character set used by the dumps.static Database.NameINFORMATION_SCHEMAstatic Database.NameMYSQLstatic Database.NameMYSQLMONstatic Database.NamePERFORMANCE_SCHEMAstatic Database.NameSYS-
Fields inherited from class com.aoindustries.aoserv.client.CachedObjectIntegerKey
pkey
-
Fields inherited from class com.aoindustries.aoserv.client.CachedObject
table
-
Fields inherited from class com.aoindustries.aoserv.client.AOServObject
USE_ARRAY_OF_DOMAIN, USE_SQL_DATA, USE_SQL_DATA_WRITE
-
-
Constructor Summary
Constructors Constructor Description Database()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intaddMySQLServerUser(UserServer msu, boolean canSelect, boolean canInsert, boolean canUpdate, boolean canDelete, boolean canCreate, boolean canDrop, boolean canReference, boolean canIndex, boolean canAlter, boolean canCreateTempTable, boolean canLockTables, boolean canCreateView, boolean canShowView, boolean canCreateRoutine, boolean canAlterRoutine, boolean canExecute, boolean canEvent, boolean canTrigger)Deprecated.List<Database.CheckTableResult>checkTables(MysqlReplication mysqlSlave, Collection<Table_Name> tableNames)Gets the table status on the master server or provided slave server.List<Database.CheckTableResult>checkTables(Collection<Table_Name> tableNames)Gets the table status on the master server.voiddump(boolean gzip, StreamHandler streamHandler)Dumps the database inDUMP_ENCODINGencoding into binary form, optionally gzipped.voiddump(PrintWriter out)Dumps the contents of this object into aWritervoiddump(Writer out)Dumps the database into textual representation, not gzipped.List<CannotRemoveReason<Database>>getCannotRemoveReasons()Lists the reasons an object may not be removed.protected ObjectgetColumnImpl(int i)StringgetJdbcDocumentationUrl()Gets the URL of the JDBC documentation.StringgetJdbcDriver()Gets the classname of the driver used to contact the server.StringgetJdbcUrl(boolean ipOnly)Gets the URL that should be used for JDBC connections.AlertLevelgetMaxCheckTableAlertLevel()DatabaseUsergetMySQLDBUser(UserServer msu)List<DatabaseUser>getMySQLDBUsers()ServergetMySQLServer()intgetMySQLServer_id()List<UserServer>getMySQLServerUsers()Database.NamegetName()PackagegetPackage()Account.NamegetPackage_name()Table.TableIDgetTableID()List<Database.TableStatus>getTableStatus()Gets the table status on the master server.List<Database.TableStatus>getTableStatus(MysqlReplication mysqlSlave)Gets the table status on the master server or provided slave server.voidinit(ResultSet result)Initializes this object from the raw database contents.static booleanisSafeName(String name)Deprecated.UseinsteadbooleanisSpecial()static booleanisSpecial(Database.Name name)Special MySQL databases may not be added or removed.voidread(StreamableInput in, AoservProtocol.Version protocolVersion)voidremove()Removes this object, and all dependant objects, from the system.StringtoStringImpl()AOServObject.toString()implementation that is allowed to throw exceptions.voidwrite(StreamableOutput out, AoservProtocol.Version protocolVersion)-
Methods inherited from class com.aoindustries.aoserv.client.CachedObjectIntegerKey
equals, getKey, getPkey, hashCode
-
Methods inherited from class com.aoindustries.aoserv.client.CachedObject
getTable, setTable
-
Methods inherited from class com.aoindustries.aoserv.client.AOServObject
compare, compare, compare, compare, compareIgnoreCaseConsistentWithEquals, compareTo, compareTo, compareTo, getAccountingCode, getColumn, getColumns, getColumns, getDomainLabel, getDomainLabels, getDomainName, getDto, getEmail, getGecos, getGroupId, getHashedKey, getHashedPassword, getHostname, getInetAddress, getLinuxID, getLinuxUserName, getMacAddress, getMySQLDatabaseName, getMySQLServerName, getMysqlUserName, getPort, getPostgresDatabaseName, getPostgresServerName, getPostgresUserId, getTableSchema, getTimeMillis, getTimeMillis, getUnixPath, getUserId, read, toString, write
-
-
-
-
Field Detail
-
CENTOS_JDBC_DRIVER
public static final String CENTOS_JDBC_DRIVER
The classname of the JDBC driver used for theMySQLDatabase.- See Also:
- Constant Field Values
-
CENTOS_7_JDBC_DRIVER
public static final String CENTOS_7_JDBC_DRIVER
The classname of the JDBC driver used for theMySQLDatabase.- See Also:
- Constant Field Values
-
CENTOS_JDBC_DOCUMENTATION_URL
public static final String CENTOS_JDBC_DOCUMENTATION_URL
The URL for MySQL JDBC documentation.- See Also:
- Constant Field Values
-
CENTOS_7_JDBC_DOCUMENTATION_URL
public static final String CENTOS_7_JDBC_DOCUMENTATION_URL
The URL for MySQL JDBC documentation.- See Also:
- Constant Field Values
-
MYSQL
public static final Database.Name MYSQL
-
INFORMATION_SCHEMA
public static final Database.Name INFORMATION_SCHEMA
-
PERFORMANCE_SCHEMA
public static final Database.Name PERFORMANCE_SCHEMA
-
SYS
public static final Database.Name SYS
-
MYSQLMON
public static final Database.Name MYSQLMON
-
DUMP_ENCODING
public static final Charset DUMP_ENCODING
The character set used by the dumps.
-
-
Method Detail
-
isSpecial
public static boolean isSpecial(Database.Name name)
Special MySQL databases may not be added or removed.
-
addMySQLServerUser
@Deprecated public int addMySQLServerUser(UserServer msu, boolean canSelect, boolean canInsert, boolean canUpdate, boolean canDelete, boolean canCreate, boolean canDrop, boolean canReference, boolean canIndex, boolean canAlter, boolean canCreateTempTable, boolean canLockTables, boolean canCreateView, boolean canShowView, boolean canCreateRoutine, boolean canAlterRoutine, boolean canExecute, boolean canEvent, boolean canTrigger) throws IOException, SQLException
Deprecated.- Throws:
IOExceptionSQLException
-
dump
public void dump(PrintWriter out) throws IOException, SQLException
Description copied from interface:DumpableDumps the contents of this object into aWriter- Specified by:
dumpin interfaceDumpable- Throws:
IOExceptionSQLException- See Also:
dump(java.io.Writer)
-
dump
public void dump(Writer out) throws IOException, SQLException
Dumps the database into textual representation, not gzipped.- Throws:
IOExceptionSQLException
-
dump
public void dump(boolean gzip, StreamHandler streamHandler) throws IOException, SQLExceptionDumps the database inDUMP_ENCODINGencoding into binary form, optionally gzipped.- Throws:
IOExceptionSQLException
-
getColumnImpl
protected Object getColumnImpl(int i)
- Specified by:
getColumnImplin classAOServObject<Integer,Database>
-
getJdbcDriver
public String getJdbcDriver() throws SQLException, IOException
Description copied from interface:JdbcProviderGets the classname of the driver used to contact the server.- Specified by:
getJdbcDriverin interfaceJdbcProvider- Throws:
SQLExceptionIOException
-
getJdbcUrl
public String getJdbcUrl(boolean ipOnly) throws SQLException, IOException
Description copied from interface:JdbcProviderGets the URL that should be used for JDBC connections.- Specified by:
getJdbcUrlin interfaceJdbcProvider- Throws:
SQLExceptionIOException
-
getJdbcDocumentationUrl
public String getJdbcDocumentationUrl() throws SQLException, IOException
Description copied from interface:JdbcProviderGets the URL of the JDBC documentation.- Specified by:
getJdbcDocumentationUrlin interfaceJdbcProvider- Throws:
SQLExceptionIOException
-
getMySQLDBUser
public DatabaseUser getMySQLDBUser(UserServer msu) throws IOException, SQLException
- Throws:
IOExceptionSQLException
-
getMySQLDBUsers
public List<DatabaseUser> getMySQLDBUsers() throws IOException, SQLException
- Throws:
IOExceptionSQLException
-
getMySQLServerUsers
public List<UserServer> getMySQLServerUsers() throws IOException, SQLException
- Throws:
IOExceptionSQLException
-
getName
public Database.Name getName()
-
isSpecial
public boolean isSpecial()
-
getPackage_name
public Account.Name getPackage_name()
-
getPackage
public Package getPackage() throws SQLException, IOException
- Throws:
SQLExceptionIOException
-
getMySQLServer_id
public int getMySQLServer_id()
-
getMySQLServer
public Server getMySQLServer() throws SQLException, IOException
- Throws:
SQLExceptionIOException
-
getMaxCheckTableAlertLevel
public AlertLevel getMaxCheckTableAlertLevel()
-
getTableID
public Table.TableID getTableID()
- Specified by:
getTableIDin classAOServObject<Integer,Database>
-
init
public void init(ResultSet result) throws SQLException
Description copied from class:AOServObjectInitializes this object from the raw database contents.- Specified by:
initin classAOServObject<Integer,Database>- Parameters:
result- theResultSetcontaining the row to copy into this object- Throws:
SQLException
-
read
public void read(StreamableInput in, AoservProtocol.Version protocolVersion) throws IOException
- Specified by:
readin interfaceAOServReadable- Specified by:
readin interfaceAOServStreamable- Specified by:
readin classAOServObject<Integer,Database>- Throws:
IOException
-
getCannotRemoveReasons
public List<CannotRemoveReason<Database>> getCannotRemoveReasons() throws SQLException, IOException
Description copied from interface:RemovableLists the reasons an object may not be removed.- Specified by:
getCannotRemoveReasonsin interfaceRemovable- Returns:
- an empty
List<CannotRemoveReason>if this object may be removed, or a list of descriptions - Throws:
SQLExceptionIOException
-
remove
public void remove() throws IOException, SQLExceptionDescription copied from interface:RemovableRemoves this object, and all dependant objects, from the system.- Specified by:
removein interfaceRemovable- Throws:
IOExceptionSQLException
-
toStringImpl
public String toStringImpl()
Description copied from class:AOServObjectAOServObject.toString()implementation that is allowed to throw exceptions.Implementation Note:
This default implementation callsAOServObject.toString()on the key (fromAOServObject.getKey()). When the key isnull, uses the default implementation fromObject.toString().- Overrides:
toStringImplin classCachedObjectIntegerKey<Database>
-
write
public void write(StreamableOutput out, AoservProtocol.Version protocolVersion) throws IOException
- Specified by:
writein interfaceAOServStreamable- Specified by:
writein interfaceAOServWritable- Specified by:
writein classAOServObject<Integer,Database>- Throws:
IOException
-
getTableStatus
public List<Database.TableStatus> getTableStatus() throws IOException, SQLException
Gets the table status on the master server.- Throws:
IOExceptionSQLException
-
getTableStatus
public List<Database.TableStatus> getTableStatus(MysqlReplication mysqlSlave) throws IOException, SQLException
Gets the table status on the master server or provided slave server.- Throws:
IOExceptionSQLException
-
checkTables
public List<Database.CheckTableResult> checkTables(Collection<Table_Name> tableNames) throws IOException, SQLException
Gets the table status on the master server.- Throws:
IOExceptionSQLException
-
checkTables
public List<Database.CheckTableResult> checkTables(MysqlReplication mysqlSlave, Collection<Table_Name> tableNames) throws IOException, SQLException
Gets the table status on the master server or provided slave server.- Throws:
IOExceptionSQLException
-
isSafeName
@Deprecated public static boolean isSafeName(String name)
Deprecated.UseinsteadDetermines if a name is safe for use as a table/column name, the name identifier should be enclosed with backticks (`).
-
-