2

I've been working a bit with H2 over the past couple of days, and I am having some trouble. I run the program on one computer and add some data. Then, I try to run the same program on another computer (even through a shared folder over the peer-to-peer network), and it seems as though the database is stored locally, on each computer.

Now, I have a database set up with the URL jdbc:h2:C://DatabaseTesting/NewDatabase. I couldn't get it placed in certain other folders, but I figured this one will do.

Now, if I try to run this program on multiple computers, I can already see what the issue will be. It will create the database on each computer, locally, instead of only on the "server" computer. How can I get all of the computers to link back to the "server" computer for this application?

55
  • 2
    In "File" mode, the database will only run in "single user mode" or "single connection mode", this makes it great for applications that want the power of a database for a single user. H2 also has a server mode. I suggest having a read through the documents Oct 31, 2014 at 4:01
  • I read over their documents. Is server mode the only option for connecting to the database in this manner?
    – Ryan
    Oct 31, 2014 at 4:04
  • If you want to share the database with more than one user at a time, yes. Oct 31, 2014 at 4:06
  • This time, I used jdbc:h2:tcp://localhost/~/NewDatabase, but it didn't work on any other computer except the computer that I developed the application on. How do I get the database to be shared via a shared folder over a network? Thank you for the help.
    – Ryan
    Oct 31, 2014 at 4:25
  • 1- Did you run the server process? 2- If you only need a single user to access the database at a time, you should use a variable connection path, so you can configure it. Allowing multiple computers to connect to the H2 in "file" mode is a really, really bad idea Oct 31, 2014 at 4:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.