且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

配置Liberty Profile以使用H2数据库

更新时间:2023-01-18 16:51:07

这是wlp的server.xml中我正在使用的h2配置:

This is my working h2 configuration in the server.xml of the wlp:

<dataSource
    id="mydb"
    jndiName="jdbc/mydb"
    type="javax.sql.ConnectionPoolDataSource">
    <jdbcDriver
        javax.sql.ConnectionPoolDataSource="org.h2.jdbcx.JdbcDataSource"
        javax.sql.DataSource="org.h2.jdbcx.JdbcDataSource"
        javax.sql.XADataSource="org.h2.jdbcx.JdbcDataSource"
        libraryRef="SharedLibrary_H2"/>
    <properties
        URL="jdbc:h2:C:/Apps/db/h2/mydb.db;MV_STORE=FALSE;AUTO_SERVER=TRUE"
        databaseName="MY_DB"
        user="sa"
        password="sa" />
   </dataSource>

<library id="SharedLibrary_H2">
    <fileset dir="${shared.resource.dir}/h2" id="Fileset_H2"/>
</library>

h2.jar必须在以下位置可用:

The h2.jar must be available at:

C:\path\to\wlp\usr\shared\resources\h2\h2-1.4.187.jar

在peristence.xml的持久性单元中:

In the persistence unit of your peristence.xml:

<jta-data-source>jdbc/mydb</jta-data-source>