Setting up an embedded Derby database in a standalone Java application

后端 未结 5 1663
你的背包
你的背包 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:59

    To use Derby in Java in embedded mode, we need to do the following steps:

    • Use the org.apache.derby.jdbc.EmbeddedDriver driver, located in the derbyclient Maven dependency
    • Use the connection string for embedded mode: jdbc:derby:dbname
    • Set up the Derby system home: System.setProperty("derby.system.home", "/home/janbodnar/.derby");
    • Shut down Derby programatically at the end: DriverManager.getConnection("jdbc:derby:;shutdown=true");
    • Handle XJ015 error, which is triggered at successfull shutdown

    Full working examples can be found at my Java JDBC Derby programming tutorial.

提交回复
热议问题