Class FBManager
- java.lang.Object
- 
- org.firebirdsql.management.FBManager
 
- 
- All Implemented Interfaces:
- java.lang.AutoCloseable,- AttachmentProperties,- BaseProperties,- FBManagerMBean
 
 public class FBManager extends java.lang.Object implements FBManagerMBean A tool for creating and dropping databases.In particular, they can be created and dropped using the jboss service lifecycle operations start and stop. See FBManagerMBeanfor documentation.- Author:
- David Jencks
 
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Alias forFBManagerMBean.stop()java.util.Map<ConnectionProperty,java.lang.Object>connectionPropertyValues()An unmodifiable view on the connection properties held by this BaseProperties implementation.voidcreateDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password)Create a database with the specified file name, username and password on the specifiedserverandport.voidcreateDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password, java.lang.String roleName)Create a database with the specified file name, username, password and role on the specifiedserverandport.voiddropDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password)Drop a database with the specified file name, username and password on the specifiedserverandport.voiddropDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password, java.lang.String roleName)Drop a database with the specified file name, username, password and role on the specifiedserverandport.java.lang.StringgetAuthPlugins()Get the list of authentication plugins to try.java.lang.BooleangetBooleanProperty(java.lang.String name)Retrieves abooleanproperty value by name.java.lang.StringgetDefaultCharacterSet()intgetDialect()java.lang.StringgetFileName()java.lang.BooleangetForceWrite()java.lang.IntegergetIntProperty(java.lang.String name)Retrieves anintproperty value by name.java.lang.StringgetName()intgetPageSize()java.lang.StringgetPassword()intgetPort()intgetPortNumber()Get the port number of the server.java.lang.StringgetProperty(java.lang.String name)Retrieves a string property value by name.java.lang.StringgetRoleName()java.lang.StringgetServer()java.lang.StringgetServerName()Get the hostname or IP address of the Firebird server.java.lang.StringgetState()java.lang.StringgetType()java.lang.StringgetUser()java.lang.StringgetUserName()booleanisCreateOnStart()Get if the database will be created when callingFBManagerMBean.start().booleanisDatabaseExists(java.lang.String fileName, java.lang.String user, java.lang.String password)Check if a database exists with the specified file name, username and password on the specifiedserverandport.booleanisDropOnStop()Get if the database will be created when callingFBManagerMBean.stop().booleanisForceCreate()Get if the database will be dropped if exists when creating a database.voidsetAuthPlugins(java.lang.String authPlugins)Sets the authentication plugins to try.voidsetBooleanProperty(java.lang.String name, java.lang.Boolean value)Sets abooleanproperty by name.voidsetCreateOnStart(boolean createOnStart)Set if the database will be created when callingFBManagerMBean.start().voidsetDefaultCharacterSet(java.lang.String firebirdCharsetName)Set the default database character set to use when creating a new database.voidsetDialect(int dialect)Set the database dialect to use when creating a new database.voidsetDropOnStop(boolean dropOnStop)Set if the database will be created when callingFBManagerMBean.stop().voidsetFileName(java.lang.String fileName)Set the file name or alias of the database.voidsetForceCreate(boolean forceCreate)Set if the database will be dropped if exists when creating a database.voidsetForceWrite(java.lang.Boolean forceWrite)Control force write behaviour of the created database.voidsetIntProperty(java.lang.String name, java.lang.Integer value)Sets anintproperty by name.voidsetPageSize(int pageSize)Set the page size to use when creating a new database.voidsetPassword(java.lang.String password)voidsetPort(int port)Set the port of the Firebird server.voidsetPortNumber(int portNumber)Set the port number of the server.voidsetProperty(java.lang.String name, java.lang.String value)Sets a property by name.voidsetRoleName(java.lang.String roleName)voidsetServer(java.lang.String host)Set the hostname of the Firebird server.voidsetServerName(java.lang.String serverName)Set the hostname or IP address of the Firebird server.voidsetType(java.lang.String type)voidsetUser(java.lang.String user)voidsetUserName(java.lang.String userName)Set the username.voidstart()Start this manager.voidstop()Stop this manager.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.firebirdsql.jaybird.props.AttachmentPropertiesgetCharSet, getConnectTimeout, getDbCryptConfig, getEncoding, getParallelWorkers, getProcessId, getProcessName, getSocketBufferSize, getSoTimeout, getWireCrypt, isWireCompression, setCharSet, setConnectTimeout, setDbCryptConfig, setEncoding, setParallelWorkers, setProcessId, setProcessName, setSocketBufferSize, setSoTimeout, setWireCompression, setWireCrypt
 - 
Methods inherited from interface org.firebirdsql.jaybird.props.BasePropertiesgetBooleanProperty, getIntProperty, getProperty
 
- 
 
- 
- 
- 
Constructor Detail- 
FBManagerpublic FBManager() 
 - 
FBManagerpublic FBManager(GDSType type) 
 - 
FBManagerpublic FBManager(java.lang.String type) 
 
- 
 - 
Method Detail- 
startpublic void start() throws java.lang.ExceptionDescription copied from interface:FBManagerMBeanStart this manager.If FBManagerMBean.isCreateOnStart()istrue, will attempt to create a new database specified using theserver,port,fileNameand related properties. If the specified already exists, nothing will be created unlessFBManagerMBean.isForceCreate()istrue. WhenforceCreateistruean attempt will be made to drop the database.- Specified by:
- startin interface- FBManagerMBean
- Throws:
- java.lang.IllegalStateException- If this manager is not started
- java.lang.Exception- For failures to start or create the database
 
 - 
stoppublic void stop() throws java.lang.ExceptionDescription copied from interface:FBManagerMBeanStop this manager.If FBManagerMBean.isDropOnStop()istrue, will attempt to drop the database specified using theserver,port,fileNameand related properties,If the manager is currently stopped, this method will do nothing. - Specified by:
- stopin interface- FBManagerMBean
- Throws:
- java.lang.Exception- For failures to drop the database.
 
 - 
closepublic void close() throws java.lang.ExceptionDescription copied from interface:FBManagerMBeanAlias forFBManagerMBean.stop()- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- FBManagerMBean
- Throws:
- java.lang.Exception
 
 - 
getStatepublic java.lang.String getState() - Specified by:
- getStatein interface- FBManagerMBean
- Returns:
- Current state ("Stopped"or"Started"
 
 - 
getNamepublic java.lang.String getName() - Specified by:
- getNamein interface- FBManagerMBean
- Returns:
- Descriptive name of this manager
 
 - 
setServerNamepublic void setServerName(java.lang.String serverName) Description copied from interface:AttachmentPropertiesSet the hostname or IP address of the Firebird server.When set to null(the default), thedatabaseNameorserviceNameis used as the full identification of the database host, port and database path/alias. Protocol implementations, for examplePURE_JAVA, may default tolocalhostwhen this property isnull, butdatabaseName/serviceNamedoes not (seem to) contain a host name.- Specified by:
- setServerNamein interface- AttachmentProperties
- Parameters:
- serverName- Hostname or IP address of the server
 
 - 
getServerNamepublic java.lang.String getServerName() Description copied from interface:AttachmentPropertiesGet the hostname or IP address of the Firebird server.- Specified by:
- getServerNamein interface- AttachmentProperties
- Returns:
- Hostname or IP address of the server
- See Also:
- AttachmentProperties.setServerName(String)
 
 - 
setServerpublic void setServer(java.lang.String host) Description copied from interface:FBManagerMBeanSet the hostname of the Firebird server.- Specified by:
- setServerin interface- FBManagerMBean
- Parameters:
- host- hostname
- See Also:
- AttachmentProperties.setServerName(String)
 
 - 
getServerpublic java.lang.String getServer() - Specified by:
- getServerin interface- FBManagerMBean
- Returns:
- hostname of the Firebird server (default is "localhost")
- See Also:
- AttachmentProperties.setServerName(String)
 
 - 
setPortNumberpublic void setPortNumber(int portNumber) Description copied from interface:AttachmentPropertiesSet the port number of the server.Defaults to 3050. This property value will be ignored ifserverNameisnull, unless the protocol implementation needs a hostname, but cannot find a hostname indatabaseName/serviceName.- Specified by:
- setPortNumberin interface- AttachmentProperties
- Parameters:
- portNumber- Port number of the server
- See Also:
- AttachmentProperties.setServerName(String)
 
 - 
getPortNumberpublic int getPortNumber() Description copied from interface:AttachmentPropertiesGet the port number of the server.- Specified by:
- getPortNumberin interface- AttachmentProperties
- Returns:
- Port number of the server
- See Also:
- AttachmentProperties.setPortNumber(int)
 
 - 
setPortpublic void setPort(int port) Description copied from interface:FBManagerMBeanSet the port of the Firebird server.- Specified by:
- setPortin interface- FBManagerMBean
- Parameters:
- port- port of the Firebird server
- See Also:
- AttachmentProperties.setPortNumber(int)
 
 - 
getPortpublic int getPort() - Specified by:
- getPortin interface- FBManagerMBean
- Returns:
- port of the Firebird server (default is 3050)
- See Also:
- AttachmentProperties.getPortNumber()
 
 - 
getFileNamepublic java.lang.String getFileName() - Specified by:
- getFileNamein interface- FBManagerMBean
- Returns:
- File name or alias of the database
 
 - 
setFileNamepublic void setFileName(java.lang.String fileName) Description copied from interface:FBManagerMBeanSet the file name or alias of the database.- Specified by:
- setFileNamein interface- FBManagerMBean
- Parameters:
- fileName- File name or alias of the database
 
 - 
getTypepublic java.lang.String getType() - Specified by:
- getTypein interface- AttachmentProperties
- Returns:
- type of the connection, for example, "PURE_JAVA", "NATIVE", "EMBEDDED", depends on the GDS implementations installed in the system.
 
 - 
setTypepublic void setType(java.lang.String type) - Specified by:
- setTypein interface- AttachmentProperties
- Parameters:
- type- type of the connection, for example, "PURE_JAVA", "NATIVE", "EMBEDDED", depends on the GDS implementations installed in the system.
 
 - 
getUserpublic java.lang.String getUser() - Specified by:
- getUserin interface- AttachmentProperties
- Returns:
- Name of the user to authenticate to the server.
 
 - 
setUserpublic void setUser(java.lang.String user) - Specified by:
- setUserin interface- AttachmentProperties
- Parameters:
- user- Name of the user to authenticate to the server.
 
 - 
getUserNamepublic java.lang.String getUserName() - Specified by:
- getUserNamein interface- FBManagerMBean
- Returns:
- username
- See Also:
- AttachmentProperties.getUser()
 
 - 
setUserNamepublic void setUserName(java.lang.String userName) Description copied from interface:FBManagerMBeanSet the username.- Specified by:
- setUserNamein interface- FBManagerMBean
- Parameters:
- userName- username
- See Also:
- AttachmentProperties.setUser(String)
 
 - 
getPasswordpublic java.lang.String getPassword() - Specified by:
- getPasswordin interface- AttachmentProperties
- Returns:
- Password to authenticate to the server.
 
 - 
setPasswordpublic void setPassword(java.lang.String password) - Specified by:
- setPasswordin interface- AttachmentProperties
- Parameters:
- password- Password to authenticate to the server.
 
 - 
getRoleNamepublic java.lang.String getRoleName() - Specified by:
- getRoleNamein interface- AttachmentProperties
- Returns:
- SQL role to use.
 
 - 
setRoleNamepublic void setRoleName(java.lang.String roleName) - Specified by:
- setRoleNamein interface- AttachmentProperties
- Parameters:
- roleName- SQL role to use.
 
 - 
getAuthPluginspublic java.lang.String getAuthPlugins() Description copied from interface:AttachmentPropertiesGet the list of authentication plugins to try.- Specified by:
- getAuthPluginsin interface- AttachmentProperties
- Returns:
- comma-separated list of authentication plugins
 
 - 
setAuthPluginspublic void setAuthPlugins(java.lang.String authPlugins) Description copied from interface:AttachmentPropertiesSets the authentication plugins to try.Invalid names are skipped during authentication. - Specified by:
- setAuthPluginsin interface- AttachmentProperties
- Parameters:
- authPlugins- comma-separated list of authentication plugins
 
 - 
setDialectpublic void setDialect(int dialect) Description copied from interface:FBManagerMBeanSet the database dialect to use when creating a new database.- Specified by:
- setDialectin interface- FBManagerMBean
- Parameters:
- dialect- Database dialect (1 or 3)
- See Also:
- FBManagerMBean.getDialect()
 
 - 
getDialectpublic int getDialect() - Specified by:
- getDialectin interface- FBManagerMBean
- Returns:
- Database dialect (either 1 or 3), default is 3.
 
 - 
setPageSizepublic void setPageSize(int pageSize) Description copied from interface:FBManagerMBeanSet the page size to use when creating a new database.The value for pageSizemust be one ofPageSizeConstants. The default value depends on the Firebird version.Some values are not valid on all Firebird versions. - Specified by:
- setPageSizein interface- FBManagerMBean
- Parameters:
- pageSize- The page size to be used in the created database, see- PageSizeConstants
- See Also:
- PageSizeConstants
 
 - 
getPageSizepublic int getPageSize() - Specified by:
- getPageSizein interface- FBManagerMBean
- Returns:
- The page size to be used when creating a database, or -1if the database default is used.
 
 - 
setDefaultCharacterSetpublic void setDefaultCharacterSet(java.lang.String firebirdCharsetName) Description copied from interface:FBManagerMBeanSet the default database character set to use when creating a new database.- Specified by:
- setDefaultCharacterSetin interface- FBManagerMBean
- Parameters:
- firebirdCharsetName- Character set name, use Firebird names only;- nullwill use Firebird default (- NONE). Specifying an invalid name will result in an exception during database creation.
 
 - 
getDefaultCharacterSetpublic java.lang.String getDefaultCharacterSet() - Specified by:
- getDefaultCharacterSetin interface- FBManagerMBean
- Returns:
- The default character set name, nullmeans not set.
- See Also:
- FBManagerMBean.setDefaultCharacterSet(String)
 
 - 
setForceWritepublic void setForceWrite(java.lang.Boolean forceWrite) Description copied from interface:FBManagerMBeanControl force write behaviour of the created database.Only use this method if you know what you're doing, and if you can live with data loss and database corruption. In general it is advisable to use the Firebird default ( nullfor this method).- Specified by:
- setForceWritein interface- FBManagerMBean
- Parameters:
- forceWrite-- null- default behaviour (force write enabled after database creation and initialization),- true- enable force write at database creation,- false- disable force write
 
 - 
getForceWritepublic java.lang.Boolean getForceWrite() - Specified by:
- getForceWritein interface- FBManagerMBean
- Returns:
- The forced writes configuration
- See Also:
- FBManagerMBean.setForceWrite(Boolean)
 
 - 
isCreateOnStartpublic boolean isCreateOnStart() Description copied from interface:FBManagerMBeanGet if the database will be created when callingFBManagerMBean.start().- Specified by:
- isCreateOnStartin interface- FBManagerMBean
- Returns:
- truewhen the database will be created on start,- falseotherwise.
 
 - 
setCreateOnStartpublic void setCreateOnStart(boolean createOnStart) Description copied from interface:FBManagerMBeanSet if the database will be created when callingFBManagerMBean.start().- Specified by:
- setCreateOnStartin interface- FBManagerMBean
- Parameters:
- createOnStart-- trueto create the database on start,- falseto not create on start (default)
 
 - 
isDropOnStoppublic boolean isDropOnStop() Description copied from interface:FBManagerMBeanGet if the database will be created when callingFBManagerMBean.stop().- Specified by:
- isDropOnStopin interface- FBManagerMBean
- Returns:
- trueto drop the database on stop,- falseotherwise
 
 - 
setDropOnStoppublic void setDropOnStop(boolean dropOnStop) Description copied from interface:FBManagerMBeanSet if the database will be created when callingFBManagerMBean.stop().- Specified by:
- setDropOnStopin interface- FBManagerMBean
- Parameters:
- dropOnStop-- trueto drop the database on stop,- falseto not drop on stop (default)
 
 - 
isForceCreatepublic boolean isForceCreate() Description copied from interface:FBManagerMBeanGet if the database will be dropped if exists when creating a database.- Specified by:
- isForceCreatein interface- FBManagerMBean
- Returns:
- trueto drop existing database on create,- falseto not create a database if it exists.
 
 - 
setForceCreatepublic void setForceCreate(boolean forceCreate) Description copied from interface:FBManagerMBeanSet if the database will be dropped if exists when creating a database.- Specified by:
- setForceCreatein interface- FBManagerMBean
- Parameters:
- forceCreate-- trueto drop existing database on create,- falseto not create a database if it exists.
 
 - 
createDatabasepublic void createDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password) throws java.lang.ExceptionDescription copied from interface:FBManagerMBeanCreate a database with the specified file name, username and password on the specifiedserverandport.On creation, the following properties will used to configure the database: dialect,pageSize,defaultCharacterSet.If the database already exists, and forceCreateistrue, the database will be dropped. Iffalse, no database will be created.- Specified by:
- createDatabasein interface- FBManagerMBean
- Parameters:
- fileName- Database file name or alias
- user- User name
- password- Password
- Throws:
- java.lang.IllegalStateException- If this manager is not started
- java.lang.Exception- If database creation fails.
 
 - 
createDatabasepublic void createDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password, java.lang.String roleName) throws java.lang.ExceptionDescription copied from interface:FBManagerMBeanCreate a database with the specified file name, username, password and role on the specifiedserverandport.On creation, the following properties will used to configure the database: dialect,pageSize,defaultCharacterSet.If the database already exists, and forceCreateistrue, the database will be dropped. Iffalse, no database will be created.- Specified by:
- createDatabasein interface- FBManagerMBean
- Parameters:
- fileName- Database file name or alias
- user- User name
- password- Password
- roleName- Role name (or- nullfor no role)
- Throws:
- java.lang.IllegalStateException- If this manager is not started
- java.lang.Exception- If database creation fails.
 
 - 
dropDatabasepublic void dropDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password) throws java.lang.ExceptionDescription copied from interface:FBManagerMBeanDrop a database with the specified file name, username and password on the specifiedserverandport.- Specified by:
- dropDatabasein interface- FBManagerMBean
- Parameters:
- fileName- Database file name or alias
- user- User name
- password- Password
- Throws:
- java.lang.Exception- If this manager is not started or database drop fails.
 
 - 
dropDatabasepublic void dropDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password, java.lang.String roleName) throws java.lang.ExceptionDescription copied from interface:FBManagerMBeanDrop a database with the specified file name, username, password and role on the specifiedserverandport.- Specified by:
- dropDatabasein interface- FBManagerMBean
- Parameters:
- fileName- Database file name or alias
- user- User name
- password- Password
- roleName- Role name (or- nullfor no role)
- Throws:
- java.lang.Exception- If this manager is not started or database drop fails.
 
 - 
isDatabaseExistspublic boolean isDatabaseExists(java.lang.String fileName, java.lang.String user, java.lang.String password) throws java.lang.ExceptionDescription copied from interface:FBManagerMBeanCheck if a database exists with the specified file name, username and password on the specifiedserverandport.Existence is checked by connecting to the database, so any connection error, including invalid credentials, will report the database as not existing. - Specified by:
- isDatabaseExistsin interface- FBManagerMBean
- Parameters:
- fileName- Database file name or alias
- user- User name
- password- Password
- Returns:
- trueif the database exists and can be connected,- falseif the database does not exist or any other error occurred.
- Throws:
- java.lang.Exception- Currently no other exception is thrown, this may change in the future
 
 - 
getPropertypublic final java.lang.String getProperty(java.lang.String name) Description copied from interface:BasePropertiesRetrieves a string property value by name.For properties with an explicit default, this method should return the string presentation of that default, not null. Forintorbooleanthe string equivalent is returned.- Specified by:
- getPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- Returns:
- Value of the property, or nullwhen not set or not a known property
 
 - 
setPropertypublic final void setProperty(java.lang.String name, java.lang.String value)Description copied from interface:BasePropertiesSets a property by name.This method can be used to set all defined properties, but also properties not known by Jaybird. When setting intorbooleanproperties, the appropriate conversions are applied. Usingnullwill reset to the default value. Forbooleanproperties, an empty string is taken to meantrue.- Specified by:
- setPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- value- Property value (use- nullto apply default)
 
 - 
getIntPropertypublic final java.lang.Integer getIntProperty(java.lang.String name) Description copied from interface:BasePropertiesRetrieves anintproperty value by name.For properties with an explicit default, this method should return the integer presentation of that default. For implementation simplicity, it is allowed to convert any string property to intinstead of checking if something is actually anintproperty- Specified by:
- getIntPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- Returns:
- Integer with value of the property, or nullwhen not set
 
 - 
setIntPropertypublic final void setIntProperty(java.lang.String name, java.lang.Integer value)Description copied from interface:BasePropertiesSets anintproperty by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent. - Specified by:
- setIntPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- value- Property value (use- nullto apply default)
 
 - 
getBooleanPropertypublic final java.lang.Boolean getBooleanProperty(java.lang.String name) Description copied from interface:BasePropertiesRetrieves abooleanproperty value by name.For properties with an explicit default, this method should return the boolean presentation of that default. For implementation simplicity, it is allowed to convert any string property to booleaninstead of checking if something is actually anintproperty- Specified by:
- getBooleanPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- Returns:
- Integer with value of the property, or nullwhen not set
 
 - 
setBooleanPropertypublic final void setBooleanProperty(java.lang.String name, java.lang.Boolean value)Description copied from interface:BasePropertiesSets abooleanproperty by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent. - Specified by:
- setBooleanPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- value- Property value (use- nullto apply default)
 
 - 
connectionPropertyValuespublic final java.util.Map<ConnectionProperty,java.lang.Object> connectionPropertyValues() Description copied from interface:BasePropertiesAn unmodifiable view on the connection properties held by this BaseProperties implementation.Be aware, implementations can have additional properties that are not mapped from ConnectionProperty. Such properties will need to be retrieved in an implementation-specific manner.- Specified by:
- connectionPropertyValuesin interface- BaseProperties
- Returns:
- An unmodifiable view on the property values held in this properties instance
 
 
- 
 
-