You are here: Client-Server


db4o's is an embedded database which usually runs in process. Nevertheless db4o also supports a client server setup. There's no ready to use db4o server, instead you embedded the db4o server in a regular application. This gives you full how you want to run the db4o server.

In order to use the db4o client server mode you need to include the db4o-X.XX-cs-javaC.jar if your not using the db4o-X.XX-all-javaX.jarDb4objects.Db4o.CS.dll-assembly in your project. See "Dependency Overview"

Start The Server

You start the server by creating a object server instance with the client server factory. Pass the database file path and the port to the factory. After that you need to specify a user-name and password which clients can use to login to this server. You can add multiple users by calling the grant access method multiple times.

ObjectServer server = Db4oClientServer.openServer("database.db4o",8080);

    // Let the server run.
} finally {
} Start a db4o server

Connect To The Server

After the server is up an running you can connect to it. Pass the URL, port, user name and password to the client server factory. This will return a client object container. After that the container is ready to use.

final ObjectContainer container
        = Db4oClientServer.openClient("localhost", 8080, "user", "password");
    // Your operations
}finally {
} Connect to the server