Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

NetBeans 6: Matisse Updates

NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed.

Introduction to Groovy Part 3

In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.

Easier Custom Components with Swing Fuse

Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Benchmark Analysis: Guice vs Spring

Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Replies: 33 - Pages: 3   [ 1 2 3 | Next ]
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

At 1:44 PM on Apr 4, 2007, Michael Urban wrote:

I know this has been discussed before, but I wanted to get the collective opinion of Javalobby members.

I'm currently working on a desktop application project that is mostly data driven, and needs to have an embedded database. Right now, I am using Hsqldb, but could swap in another database fairly easily.

My reasons for choosing Hsqldb are basically as follows:

  • It's extremely fast
  • It has a smaller footprint
  • The OpenOffice folks are using it as the database for OpenOffice, which probably speaks well of its capability as an embedded database.

However, I'm not left without a few lingering doubts about my choice, and whether I should use Derby instead:

  • Hsqldb has an 8Gb database limit, which could be an issue if I decide to store photos as blobs in the database rather than just store links to where they are on the file system.
  • Hsqldb probably doesn't scale as well as Derby, and probably isn't as "safe" if I ever wanted to to run it in server mode and allow multiple users to access the database at the same time.
  • Derby is probably more powerful, supporting more the SQL standard than Hsqldb (although so far I have not needed any of the additional features).

I would appreciate anyone's thoughts or insights on this, as well as on another related question I hinted at above:

What are the advantages and disadvantages of storing images as blobs in the database, vs. just storing references to their locations on the file system?

Thanks in advance for opinions and insights on both issues. Which would you choose and why?
1 . At 2:02 PM on Apr 4, 2007, Michael Urban wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

Well, as Mikael Grev pointed out to me, JavaDB only comes with the JDK, and not with the JRE. So I guess one of my points in favor of Derby isn't valid. Either way I need to ship a jar for end users.
2 . At 2:53 PM on Apr 4, 2007, Austin Kotlus wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

I would definitely check out H2 (http://www.h2database.com) It is being actively developed by the creator of hypersonic (H2 stands for Hypersonic 2).

It's still really new but performance, features, and security are all very impressive.
3 . At 2:59 PM on Apr 4, 2007, nikodc wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

I go for HSQLDB cos as it was said "It's extremely fast". To store 8GB+ I'd rather go for a much more sofisticated option, may be Postgres.

Did you try H2? [ http://www.h2database.com ]
From Hypersonic SQL guys.
4 . At 3:12 PM on Apr 4, 2007, Shai Almog wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

Last I checked hsql didn't support blobs bigger than 4kb ;-)
It is a great DB though, even JBoss embed it with their application server and the code is small. I actually read the code and understood it which is a great thing for a small application.
Derbi is pretty good too, I think you can't go wrong with either one of these choices.
Shai Almog vPrise Software makers of vPrise Workgroup http://wg.vprise.com/ founder of bean-properties the leading OSS properties implementation in Java https://bean-properties.dev.java.net/
5 . At 3:33 PM on Apr 4, 2007, Michael Urban wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

> Last I checked hsql didn't support blobs bigger than 4kb

Hmm. Maybe it doesn't. I didn't really check the specs about whether it supports blobs larger than that.

But again, that is only an issue if I am going to store the photos as blobs in the db, instead of just store links to where they are on the filesystem. I haven't decided how I am going to go on that yet.

Any suggestions on that aspect?
6 . At 3:50 PM on Apr 4, 2007, dev danke wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

I used HSQLDB v1.8 for a server based app and had a problem with it that made stop using it in mission critical situations.

Here's the problem: If I didn't shutdown HSQLDB nicely, ie by sending the commands CHECKPOINT or SHUTDOWN via a JDBC connection before killing the process, then occasionally HSQLDB would lose ALL the data changes I'd made during that ENTIRE session (sometimes hours worth of work). This included updates,inserts, and deletes. It did this despite the fact that a) my database was not an "in memory" type, b) I configured HSQLDB to frequently flush data to disk, and c) all my actions were in auto commit mode.

HSQLDB was the first Pure Java DB I ever worked with. No other DB I worked with ever had this problem (MS SQL Server, MySQL, Oracle, DB2, Access, RBase, Paradox, etc).

This problem did not give me a warm fuzzy feeling about HSQLDB. And I just have to have a warm fuzzy feeling about my database.

In real life, sometimes servers do go down abruptly. And in cases when I'm working on the DB manually, sometimes I forget to send a commit or shutdown message to the DB.

Nevertheless, HSQLDB worked fine for less mission-critical tasks, such as when I wanted to run functional tests on my app via Hibernate into a DB.

Despite my particular problem, I think HSQLDB is a pretty good program. Thanks HSQLDB developers! I really like it's ability to use CSV files directly as DB tables. This is very handy for testing. Pure Java databases definitely are useful in many situations.

Next, I'm going to give Derby a try.
7 . At 3:51 PM on Apr 4, 2007, Shai Almog wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

> Any suggestions on that aspect?

I was faced with the issue of storing files on the FS vs. in the DB and chose the FS only to move back to the DB and being generally unhappy about both approaches...
However, I did this all on the server side so your mileage may vary. The problem with storing in the FS is that if a transaction fails or something breaks (which is theoretically possible on the client) you end up with junk thats hard to clean up. Furthermore, maintaining the files becomes a hassle with all the day to day features added that need to consider yet another place where something can exist.
I personally used NIO, huge mistake. It has bugs on Windows where stuff just can't be deleted without a restart. So sure my deployment was Linux but that made debugging hell (just avoid nio mapped files for client applications that need to delete the file at some point).

The DB is a pain on its own, it has limits on the blob sizes which you need to figure out (the default is remarkably low in most DB's) and suddenly performance slowed to a crawl. I don't recall what I did but I spent ages with the code trying to figure out what to do for performance.
To enable DB portability I split large files to smaller sizes and I needed to store things such as meta-data (mime type, file name, size etc...) in a separate place. I needed to write custom SQL in order to access this and couldn't use my ORM to work with it.

So my bottom line is: both suck. Look at your use cases and figure out which of the problems I outlined above will be worse. The "right way" is using the DB, but the right way isn't always practical/efficient.
Shai Almog vPrise Software makers of vPrise Workgroup http://wg.vprise.com/ founder of bean-properties the leading OSS properties implementation in Java https://bean-properties.dev.java.net/
8 . At 5:10 PM on Apr 4, 2007, Demetrios Kyriakis wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

Take H2Database . It's much much faster than all the others.

Demetrios.
9 . At 5:47 PM on Apr 4, 2007, Fabrizio Giudici wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

I've been using hsqldb from 2003 since last year. Then I comparatively evaluated it against Derby (operating on disk, not in memory, since my database was quite large) and I found Derby faster, so I switched to it. I've bookmarked H2 since I heard many people talking about it - and since I'm not satisfied with Derby performance in some cases I will evaluate it. But not before going in deeper details about Derby tuning.
Fabrizio Giudici, TidalWave - We make Java work. Everywhere.
weblogs.java.net/blog/fabriziogiudici, www.tidalwave.it/blog
Member of the NetBeans Dream Team.
10 . At 9:14 PM on Apr 4, 2007, Brian S O'Neill wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

Is there any particular reason you need to use an SQL embedded database? Consider BDB-JE with a Carbonado access layer instead. It too is extremely fast and has a small footprint.

BDB-JE has no size limit, it scales very well, is super easy to set up, and it automatically recovers after crashes. With Carbonado, you also get support for BLOBs of unlimited size.
Brian S O'Neill
carbonado.sourceforge.net
11 . At 10:36 PM on Apr 4, 2007, Augusto Sellhorn wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

We've been using Pointbase for quite some time, however it's not free ...
Augusto Sellhorn
http://sellmic.com
12 . At 4:09 AM on Apr 5, 2007, Xavier Hanin wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

> Here's the problem: If I didn't shutdown HSQLDB
> nicely, ie by sending the commands CHECKPOINT or
> SHUTDOWN via a JDBC connection before killing the
> process, then occasionally HSQLDB would lose ALL the
> data changes I'd made during that ENTIRE session
> (sometimes hours worth of work). This included
> updates,inserts, and deletes. It did this despite
> the fact that a) my database was not an "in memory"
> type, b) I configured HSQLDB to frequently flush data
> to disk, and c) all my actions were in auto commit
> mode.
I had exactly the same problem, then switched to derby quite recently, and it's really working well. I kill my app embedding derby pretty often in development, and I've never run into any consistency issue or data loss. I'd say that compared to hsqldb, derby is a 'real' database engine.

Another interesting point is that Sun is providing support for JavaDB (which BTW is exactly the same as Derby, JavaDB is used only for branding AFAIK), so in case you really need experts and support, you know where to ask.

The last point is that derby developers are very responsive to users problem, I had a problem last saturday which was answered within a couple of hours by a developer from sun, very nice for a saturday :-)
13 . At 4:37 AM on Apr 5, 2007, Torbjörn Gannholm DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

As long as you can keep all your data in memory and don't mind losing data on crashes, HSQLDB is ok. I don't think HSQLDB works too well with data access from different threads, either, but I may be wrong.

Derby is a solid database with all the things you need for a solid application. It always chafed a little with me, though, maybe because the SQL is a little funky.

I usually prefer McKoi, but the GPL may not work for you.

You could consider other options like Berkeley DB for Java (OODB), or possibly even Prevayler if it fits your requirements.

As to the question of files or blobs, I agree with previous poster, both options suck in different ways. If the binary data is tightly integrated with the rest of the data I would go for blobs, otherwise files are more flexible.
Torbjörn Gannholm, Luleå, Sweden
Currently engaged in Weffo web architecture outline and the Flying Saucer xhtml and xml+css renderer
14 . At 5:18 AM on Apr 5, 2007, PJ Murray DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: Ask Javalobby: Derby vs. Hsqldb for Embedding in a Swing App?

If this is a commercial application, it might be useful for you to know that support for Apache Derby is available as Cloudscape from IBM and JavaDB from Sun (they are all the same thing).

Apache Derby started out as Cloudscape - and IBM product - so it's very professional.

Some personal experience: CodeFutures embeds Derby with its product and we've never had any problems.

Sorry, I don't have any experience with Hsqldb so I can't comment on it.
PJ Murray, CodeFutures Software

Java Code Generation for Java Persistence

Data Access Objects and Service Data Objects


thread.rss_message