Class Database
- 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.postgresql.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 Dumpable, Removable, JdbcProvider
APostgresDatabasecorresponds to a unique PostgreSQL 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:
Encoding,UserServer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDatabase.NameRepresents a name that may be used for a PostgreSQL database.
-
Field Summary
Fields Modifier and Type Field Description static Database.NameAOINDUSTRIESstatic Database.NameAOSERVstatic Database.NameAOSERV_MASTERstatic Database.NameAOWEBstatic CharsetDUMP_ENCODINGThe character set used by the dumps.static StringJDBC_DRIVERThe classname of the JDBC driver used for thePostgresDatabase.static Database.NamePOSTGRESMONstatic Database.NameTEMPLATE0static Database.NameTEMPLATE1-
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 Modifier and Type Method Description booleanallowsConnections()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)UserServergetDatDBA()intgetDatdba_id()booleangetEnablePostgis()Indicates that PostGIS should be enabled for this database.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.Database.NamegetName()EncodinggetPostgresEncoding()ServergetPostgresServer()intgetPostgresServer_bind_id()Table.TableIDgetTableID()voidinit(ResultSet result)Initializes this object from the raw database contents.booleanisSpecial()static booleanisSpecial(Database.Name name)Special PostgreSQL databases may not be added or removed.booleanisTemplate()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
-
JDBC_DRIVER
public static final String JDBC_DRIVER
The classname of the JDBC driver used for thePostgresDatabase.- See Also:
- Constant Field Values
-
TEMPLATE0
public static final Database.Name TEMPLATE0
-
TEMPLATE1
public static final Database.Name TEMPLATE1
-
POSTGRESMON
public static final Database.Name POSTGRESMON
-
AOINDUSTRIES
public static final Database.Name AOINDUSTRIES
-
AOSERV
public static final Database.Name AOSERV
-
AOSERV_MASTER
public static final Database.Name AOSERV_MASTER
-
AOWEB
public static final Database.Name AOWEB
-
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 PostgreSQL databases may not be added or removed.
-
allowsConnections
public boolean allowsConnections()
-
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
-
getEnablePostgis
public boolean getEnablePostgis()
Indicates that PostGIS should be enabled for this database.
-
getColumnImpl
protected Object getColumnImpl(int i)
- Specified by:
getColumnImplin classAOServObject<Integer,Database>
-
getDatdba_id
public int getDatdba_id()
-
getDatDBA
public UserServer getDatDBA() throws SQLException, IOException
- Throws:
SQLExceptionIOException
-
getJdbcDriver
public String getJdbcDriver()
Description copied from interface:JdbcProviderGets the classname of the driver used to contact the server.- Specified by:
getJdbcDriverin interfaceJdbcProvider
-
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
-
getName
public Database.Name getName()
-
isSpecial
public boolean isSpecial()
-
getPostgresEncoding
public Encoding getPostgresEncoding() throws SQLException, IOException
- Throws:
SQLExceptionIOException
-
getPostgresServer_bind_id
public int getPostgresServer_bind_id()
-
getPostgresServer
public Server getPostgresServer() throws SQLException, IOException
- Throws:
SQLExceptionIOException
-
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
-
isTemplate
public boolean isTemplate()
-
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
-
-