2

I'm working in a project which is using DB2 + myBatis. Currently I'm defining a concept for test automation and I consider using Java DB (former apache derby) as in memomy db for unit tests. Does anyone have experience with this? Does Java DB can be used as a kind of substitution of DB2? From what I could see it's using same dialect as DB2, but that's not enough of course

5
  • As a rule of thumb I'd say, you should test systems with the same technology you'll use in production. That does not mean that parts of the tests can use mock objects. Commented Oct 29, 2013 at 16:15
  • I wanted to use this DB in developer's env. Just trying to find a best solution for the problem when many developers run unit tests in the same time. So the concept is to use this db in developer's setup and to use DB2 in continues integration. Commented Oct 29, 2013 at 16:26
  • Using an in-memory DB for unit tests on the developer box is a great idea. For a build-server/continuous integration environment, you're probably going to want to use an actual deployed instance of the destination server, though. Note that no in-memory server I've used has perfectly duplicated all features I've tried to use in DB2, even sticking to just standard features, so there will be times you'll need to have a local server deployed on developer machines. Commented Oct 30, 2013 at 12:32
  • SQL in Java DB should be very close to DB2, because JavaDB comes from Apache Derby, which comes from IBM Cloudscape. And IBM Cloudscape had many similar things with DB2 (both from IBM), and for standard SQL could be a replacement. At the time, DB2 clients (odbc/jdbc) could access Derby databases. Commented Oct 30, 2013 at 15:42
  • Hi guys, thanks for your answers. I just wonder how do you maintain a schema in such scenario, since DB2 may contain a lot of schema features that are not supported by JAVA DB. The last thing I want to have is to maintain a dedicated schema for test DB. Commented Oct 31, 2013 at 12:51

1 Answer 1

2

I've tried this, see this question, which I had when trying to introduce integration tests using Derby for a legacy database that used DB2. How well using Java DB in place of DB2 will depend on how much DB2-specific SQL and DDL you need to support.

If you want a version of DB2 you can install on a developer machine, you could try IBM DB2 Express-C, it's a no-charge version of DB2 you can use locally.

Sign up to request clarification or add additional context in comments.

2 Comments

Hmm, about the biggest issue I ended up having with Derby was that it couldn't do CTEs (which eliminates an entire class of queries). I was told there were some random issues with stored procedures, but don't know for sure myself.
Note that Derby (or other in-mem databases I know) don't really support stored procedures either. That's been the biggest drawback for us.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.