Setting up an embedded Derby database in a standalone Java application

后端 未结 5 1653
你的背包
你的背包 2020-12-08 20:31

I\'m trying to setup an embedded Derby database for a standalone Java application, but after pouring through all sorts of documentation, I just can\'t seem to find any simpl

5条回答
  •  情歌与酒
    2020-12-08 20:51

    If you're ok with switching to the netbeans IDE here are two useful tutorials which I was able to get working in the ide (i'm having some minor issues with the installer). It uses JPA which is an abstraction that simplifies a lot of database interaction.

    https://blogs.oracle.com/geertjan/entry/embedded_database_for_netbeans_platform

    http://platform.netbeans.org/tutorials/nbm-crud.html

    To address some of your inquiries:

    1. If you're using java and relation dbs i would highly recommend JPA. Otherwise you are using JDBC to interact with your database and using SQL.
    2. Traditionally you use a utility or run a script to create the table schema however since you are going for embedded you might be interested (as i am) in having the db and schema create it self dynamically so you don't have to run this script every time you install your application. This is doable with derby's embedded JPA configuration which the tutorial covers.
    3. if you are running an embedded derby database there is no separate thread or socket that you start up. you app will use the jpa or derby api which will use file locking to access the derby files. In my definition an embedded database does not have a separate thread or process listening on a socket handling multiple request.

    Hope this helps and Good luck!

提交回复
热议问题