Interface FBManagerMBean
- 
- All Superinterfaces:
- AttachmentProperties,- java.lang.AutoCloseable,- BaseProperties
 - All Known Implementing Classes:
- FBManager
 
 public interface FBManagerMBean extends AttachmentProperties, java.lang.AutoCloseable API forFBManager, for creating and dropping databases.The class FBManagerprovides an API to create and drop databases, including options to limit the lifetime of a database// Use try-with-resources to automatically stop (close) FBManager try (FBManager manager = new FBManager()) { manager.setServer("localhost"); manager.setUser("sysdba"); manager.setPassword("masterkey"); manager.setFileName("path/to/database.fdb"); manager.setPageSize(PageSizeConstants.SIZE_16K); manager.setDefaultCharacterSet("UTF8"); // Create database when manager is started manager.setCreateOnStart(true); // Drop database on creation if it already exists manager.setForceCreate(true); // Drop database when manager is stopped manager.setDropOnStop(true); manager.start(); // Use database... } // After end of try-with-resources, the database will be dropped- Author:
- David Jencks
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Alias forstop()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.StringgetDefaultCharacterSet()intgetDialect()java.lang.StringgetFileName()java.lang.BooleangetForceWrite()java.lang.StringgetName()intgetPageSize()intgetPort()java.lang.StringgetServer()java.lang.StringgetState()java.lang.StringgetUserName()booleanisCreateOnStart()Get if the database will be created when callingstart().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 callingstop().booleanisForceCreate()Get if the database will be dropped if exists when creating a database.voidsetCreateOnStart(boolean createOnStart)Set if the database will be created when callingstart().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 callingstop().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.voidsetPageSize(int pageSize)Set the page size to use when creating a new database.voidsetPort(int port)Set the port of the Firebird server.voidsetServer(java.lang.String host)Set the hostname of the Firebird server.voidsetUserName(java.lang.String userName)Set the username.voidstart()Start this manager.voidstop()Stop this manager.- 
Methods inherited from interface org.firebirdsql.jaybird.props.AttachmentPropertiesgetAuthPlugins, getCharSet, getConnectTimeout, getDbCryptConfig, getEncoding, getParallelWorkers, getPassword, getPortNumber, getProcessId, getProcessName, getRoleName, getServerName, getSocketBufferSize, getSoTimeout, getType, getUser, getWireCrypt, isWireCompression, setAuthPlugins, setCharSet, setConnectTimeout, setDbCryptConfig, setEncoding, setParallelWorkers, setPassword, setPortNumber, setProcessId, setProcessName, setRoleName, setServerName, setSocketBufferSize, setSoTimeout, setType, setUser, setWireCompression, setWireCrypt
 - 
Methods inherited from interface org.firebirdsql.jaybird.props.BasePropertiesconnectionPropertyValues, getBooleanProperty, getBooleanProperty, getIntProperty, getIntProperty, getProperty, getProperty, setBooleanProperty, setIntProperty, setProperty
 
- 
 
- 
- 
- 
Method Detail- 
startvoid start() throws java.lang.ExceptionStart this manager.If 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 unlessisForceCreate()istrue. WhenforceCreateistruean attempt will be made to drop the database.- Throws:
- java.lang.IllegalStateException- If this manager is not started
- java.lang.Exception- For failures to start or create the database
 
 - 
stopvoid stop() throws java.lang.Exception Stop this manager.If 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. - Throws:
- java.lang.Exception- For failures to drop the database.
 
 - 
closevoid close() throws java.lang.ExceptionAlias forstop()- Specified by:
- closein interface- java.lang.AutoCloseable
- Throws:
- java.lang.Exception
 
 - 
getNamejava.lang.String getName() - Returns:
- Descriptive name of this manager
 
 - 
getStatejava.lang.String getState() - Returns:
- Current state ("Stopped"or"Started"
 
 - 
setServervoid setServer(java.lang.String host) Set the hostname of the Firebird server.- Parameters:
- host- hostname
- See Also:
- AttachmentProperties.setServerName(String)
 
 - 
getServerjava.lang.String getServer() - Returns:
- hostname of the Firebird server (default is "localhost")
- See Also:
- AttachmentProperties.setServerName(String)
 
 - 
setPortvoid setPort(int port) Set the port of the Firebird server.- Parameters:
- port- port of the Firebird server
- See Also:
- AttachmentProperties.setPortNumber(int)
 
 - 
getPortint getPort() - Returns:
- port of the Firebird server (default is 3050)
- See Also:
- AttachmentProperties.getPortNumber()
 
 - 
getFileNamejava.lang.String getFileName() - Returns:
- File name or alias of the database
 
 - 
setFileNamevoid setFileName(java.lang.String fileName) Set the file name or alias of the database.- Parameters:
- fileName- File name or alias of the database
 
 - 
getUserNamejava.lang.String getUserName() - Returns:
- username
- See Also:
- AttachmentProperties.getUser()
 
 - 
setUserNamevoid setUserName(java.lang.String userName) Set the username.- Parameters:
- userName- username
- See Also:
- AttachmentProperties.setUser(String)
 
 - 
setDialectvoid setDialect(int dialect) Set the database dialect to use when creating a new database.- Parameters:
- dialect- Database dialect (1 or 3)
- Throws:
- java.lang.IllegalArgumentException- if value is not 1 or 3
- See Also:
- getDialect()
 
 - 
getDialectint getDialect() - Returns:
- Database dialect (either 1 or 3), default is 3.
 
 - 
setPageSizevoid setPageSize(int pageSize) Set 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. - Parameters:
- pageSize- The page size to be used in the created database, see- PageSizeConstants
- See Also:
- PageSizeConstants
 
 - 
getPageSizeint getPageSize() - Returns:
- The page size to be used when creating a database, or -1if the database default is used.
 
 - 
setDefaultCharacterSetvoid setDefaultCharacterSet(java.lang.String firebirdCharsetName) Set the default database character set to use when creating a new database.- 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.
 
 - 
getDefaultCharacterSetjava.lang.String getDefaultCharacterSet() - Returns:
- The default character set name, nullmeans not set.
- See Also:
- setDefaultCharacterSet(String)
 
 - 
setForceWritevoid setForceWrite(java.lang.Boolean forceWrite) Control 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).- Parameters:
- forceWrite-- null- default behaviour (force write enabled after database creation and initialization),- true- enable force write at database creation,- false- disable force write
 
 - 
getForceWritejava.lang.Boolean getForceWrite() - Returns:
- The forced writes configuration
- See Also:
- setForceWrite(Boolean)
 
 - 
isCreateOnStartboolean isCreateOnStart() Get if the database will be created when callingstart().- Returns:
- truewhen the database will be created on start,- falseotherwise.
 
 - 
setCreateOnStartvoid setCreateOnStart(boolean createOnStart) Set if the database will be created when callingstart().- Parameters:
- createOnStart-- trueto create the database on start,- falseto not create on start (default)
 
 - 
isDropOnStopboolean isDropOnStop() Get if the database will be created when callingstop().- Returns:
- trueto drop the database on stop,- falseotherwise
 
 - 
setDropOnStopvoid setDropOnStop(boolean dropOnStop) Set if the database will be created when callingstop().- Parameters:
- dropOnStop-- trueto drop the database on stop,- falseto not drop on stop (default)
 
 - 
isForceCreateboolean isForceCreate() Get if the database will be dropped if exists when creating a database.- Returns:
- trueto drop existing database on create,- falseto not create a database if it exists.
 
 - 
setForceCreatevoid setForceCreate(boolean forceCreate) Set if the database will be dropped if exists when creating a database.- Parameters:
- forceCreate-- trueto drop existing database on create,- falseto not create a database if it exists.
 
 - 
createDatabasevoid createDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password) throws java.lang.ExceptionCreate 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.- 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.
 
 - 
createDatabasevoid createDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password, java.lang.String roleName) throws java.lang.ExceptionCreate 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.- 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.
 
 - 
dropDatabasevoid dropDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password) throws java.lang.ExceptionDrop a database with the specified file name, username and password on the specifiedserverandport.- 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.
 
 - 
dropDatabasevoid dropDatabase(java.lang.String fileName, java.lang.String user, java.lang.String password, java.lang.String roleName) throws java.lang.ExceptionDrop a database with the specified file name, username, password and role on the specifiedserverandport.- 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.
 
 - 
isDatabaseExistsboolean isDatabaseExists(java.lang.String fileName, java.lang.String user, java.lang.String password) throws java.lang.ExceptionCheck 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. - 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
 
 
- 
 
-