1

I'm trying to setup ObjectDB. I am able to create a database and view it with the explorer, using the embedded-server mode to be able to keep the explorer open while running my program. This all works fine, when my database is in the $objectdb/db/ directory.

However, I'd like to be able to do this when my database is in another directory (thus not in $objectdb/db/). When I'm not using the explorer, the database looks fine. I can also open the explorer to view the database. But... I can not keep the connection to my database open in the explorer while running my program (and thus making changes to the database).

What I have tried/have been thinking about:

  • The database and the explorer have to use the same .conf file. I think the explorer uses the conf file in the $objectdb home directory, but I can't figure out how to configure my database in the other directory to listen to that conf file, too. How can I create a project (or database) specific conf file for a database that's not in the $objectdb home directory?
    In general it feels strange to me that there would be one conf file for all your ObjectDB databases.

  • I copied both the explorer.exe and objectdb.conf to the directory my database is in, hoping this would work. However, nothing happens when I try to run the exe file. I think this is because the exe (and the explorer.jar, tried that one, too) rely on objectdb.jar, but I couldn't find that anywhere. I found objectdb-2.7.1_01.jar and copied that into the directory the database and explorer were in, but that didn't help.

As for an MWE, I followed this tutorial, using IntelliJ.

Abby
  • 1,610
  • 3
  • 19
  • 35

1 Answers1

0

Try the following:

  1. Open the database in embedded mode with a path that specifies a free port for the embedded server, e.g. "$objectdb/db/my.odb;port=9999"
  2. Access this database in client mode using "objectdb://localhost:9999", or in the Explorer, select File -> Open C/S Connection, specify 9999 as the port and keep the database path empty or /

objectdb.jar is available when you download ObjectDB as a zip file (in which you also find the Explorer), you can also rename the file from Maven, which contains a version number to objectdb.jar.

ObjectDB
  • 1,312
  • 8
  • 9
  • But then I would still be storing the database in the `$objectdb/db` directory, right? The problem is not that I cannot access my database with the explorer when it is stored in the `$objectdb/db/` directory, the problem is that I cannot do so when my database is not stored in that directory. Any tips for that? – Abby Jun 06 '17 at 15:55
  • It could be any path, e.g. "C:\\db\\my.odb;port=9999", just specify a port. An embedded server will start listening to port 9999 and you can access the database from other processes, including the Explorer using url "objectdb://localhost:9999". – ObjectDB Jun 06 '17 at 21:32
  • I think I get the idea. But I get an error that it failed to connect to server localhost:9999. In the "Open Remote Database" dialog, I kept the username and password fields empty, Host: "localhost", Port: "9999", and kept the database empty, too. My database path in my code is `C:\\...\\points.odb;port=9999`. Am I missing something? – Abby Jun 07 '17 at 11:05
  • Check that embedded server is enabled in the correct configuration file, i.e. the conf file that is used by the application that opens the database. – ObjectDB Jun 07 '17 at 17:07
  • Right, I've been googling for a while (before asking this question) how to set a configuration file for a specific application/project, but couldn't find anything. I only have one conf file in the `$objectdb` home directory. It makes sense that that cannot configure things for a database that's not in that directory. I tried to copy that conf file to the src folder of my application, but that didn't work. – Abby Jun 07 '17 at 18:34
  • I changed the conf file path before connecting to the database, using `System.setProperty("objectdb.conf", "\\mypath\\objectdb.conf")`. In the server part of the conf file I have ``, ``, and ``, but still the same problem occurs. – Abby Jun 08 '17 at 08:02
  • Try to set the configuration file using a -D parameter to the JVM. – ObjectDB Jun 08 '17 at 11:57
  • Still the same error. In the IntelliJ run configuration, I used `-Dobjectdb.conf=path/objectdb.conf` in the VM options field. I am sure that it can find the conf file, thus the path is correct, because it only worked at my second try. The first time it complained that it could not find the conf file. – Abby Jun 08 '17 at 14:17
  • Strange, it should work. Please check if a server was started listening to port 9999 (e.g. using ipstat). The port number in the configuration file has no effect (just enabling the embedded server is required in the configuration). The port should be added to the database path when opening it. – ObjectDB Jun 13 '17 at 22:34
  • I used `netstat -a`, which I think lists all connections and listening ports. It didn't show up there... – Abby Jun 14 '17 at 19:05
  • Maybe the process doesn't have a permission to bind the port? You may try other port numbers. Check also the ObjectDB log file for errors. You can also try replacing the default configuration, which is a resource in the objectdb.jar file to support embedded server. – ObjectDB Jun 14 '17 at 23:01
  • The log files are useful I guess. It says that a server is started on port 9999. I also see the exception that the connection is refused. `javax.persistence.PersistenceException Failed to connect to server localhost:9999 (Connection refused: connect) (error 522) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source)` are the first six lines of the stacktrace... – Abby Jun 15 '17 at 18:04
  • Maybe the connection is refused by a firewall? Strange that you see in the log that the server was started but cannot see it with netstat. – ObjectDB Jun 16 '17 at 08:24