startSlave=true attribute

Function

Starts replication of a database in slave mode. Before you specify this attribute, you must cleanly shut down the database on the master system and then perform a file system copy of the database to the slave system.

The startSlave=true attribute does the following:

  1. Partially boots the specified database
  2. Starts to listen on the specified port and accepts a connection from the master
  3. Hangs until the master has connected to it
  4. Reports the startup status to the caller (whether it has started, and if not, why not)
  5. Continually receives chunks of the transaction log from the master and applies the operations in the transaction log to the slave database

If replication is started successfully, an exception with the error code XRE08 is thrown. Hence, the startSlave=true attribute does not return a valid connection.

For more information, see the topics under "Replicating databases" in the Derby Server and Administration Guide.

Combining with other attributes

You must specify a database name in the connection URL, either in the subprotocol or by using the databaseName=nameofDatabase attribute.

You may specify this attribute in conjunction with the slaveHost=hostname attribute. If you do not specify the slaveHost=hostname attribute, the default value is localhost.

You may also specify this attribute in conjunction with the slavePort=portValue attribute. If you do not specify the slavePort=portValue attribute, the default port value is 4851.

If authentication is turned on, you must also specify this attribute in conjunction with the user=userName and password=userPassword attributes. If both authentication and SQL authorization are turned on, the user must be the database owner.

You may not specify this attribute in conjunction with any attributes not mentioned in this section.

Examples

-- start slave using database name in subprotocol, default slave host 
--    and port, authorization
jdbc:derby:myDB;startslave=true;user=mary;password=little88lamb
-- start slave using databaseName attribute, non-default slave host 
--   and port, no security
jdbc:derby:;databaseName=myDB;startSlave=true;slaveHost=localhost;
   slavePort=4852