Question

This is a stupid question and I know it, nevertheless I'd like to understand how these two databases are handled within my system.

I have eclipse IDE with two projects: h2_test and mysql_test, where h2_test is configured to use h2 database and mysql_test is configured to use mysql database.

In h2_test I have h2 location configured as String url = "jdbc:h2:~/h2_db" whereas in mysql_test as <property name="url" value="jdbc:mysql://localhost:3306/mysql"/>. As you might have guessed h2_test is a normal java project and mysql_test is dynamic web project.

When I run my h2_db my h2 database instance is created on my hard drive at ~/ directory. When I run my msql_db my mysql database instance is created in memory?

I must add that to actually run mysql I had to install it and run as a system.service while for h2 all I had to do is to connect a h2 driver in eclipse. Why so much hassle with mysql?

  1. Why I can't use the same logic with mysql db and create is as jdbc:mysql:~/mysql_db?
  2. How are these set-ups different and which one is preferable for a web application?
Was it helpful?

Solution

h2 DB is a standalone database, that a single Java application loads directly and operates on. Usually, a single application can use a DB at a time. Other DBs of this sort are the key-value LevelDB and Java's DB4O.

MySQL, on the other hand, is designed to be more powerful, in that it is run in a server process (written in C++). Applications (a large number simultaneously) can connect to a given MySQL server (with authentication), even from different hosts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top