postgresql_PostgreSQL开放自由
postgresql
Open Liberty是源自WebSphere Liberty的有趣的新型OSS Java EE應用服務器。 您可以將Open Liberty配置為使用PostgreSQL作為其默認數(shù)據(jù)源,如下所示:
將<datasource> , <jdbcDriver>和<library>指令添加到server.xml配置中:
<?xml version="1.0" encoding="UTF-8"?> <server description="OpenLiberty Java EE 8 Server"><featureManager><feature>javaee-7.0</feature></featureManager><httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9080" httpsPort="9443"/><keyStore id="defaultKeyStore" password="Liberty"/><!-- Postgres coffee-shop-db definition --><dataSource id="DefaultDataSource"jndiName="jdbc/sample"jdbcDriverRef="postgresql-driver"type="javax.sql.ConnectionPoolDataSource"transactional="true"><properties serverName="coffee-shop-db"portNumber="5432"databaseName="postgres"user="postgres"password="postgres"/></dataSource><jdbcDriver id="postgresql-driver"javax.sql.XADataSource="org.postgresql.xa.PGXADataSource"javax.sql.ConnectionPoolDataSource="org.postgresql.ds.PGConnectionPoolDataSource"libraryRef="postgresql-library"/><library id="postgresql-library"><fileset id="PostgreSQLFileset" dir="/opt/ol/wlp/lib"includes="postgresql-9.4-1201.jar"/></library></server>通過主機coffee-shop-db可用coffee-shop-db將通過默認的Postgres端口5432使用postgres作為數(shù)據(jù)庫名稱,用戶名和密碼)訪問。
驅動程序庫,這里是postgresql-9.4-1201.jar ,需要駐留在服務器安裝的lib/目錄中。
可以從Java EE應用程序透明地使用默認數(shù)據(jù)源。 在persistence.xml文件中只需指定一個持久性單元,類似于以下代碼片段:
<?xml version="1.0" encoding="UTF-8"?> <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistencehttp://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"><persistence-unit name="prod" transaction-type="JTA"/></persistence>如果應用程序包含多個數(shù)據(jù)庫,則要求持久性單元指定其相應數(shù)據(jù)源的JNDI名稱。
經(jīng)過官方Docker鏡像open-liberty:javaee7 。
翻譯自: https://www.javacodegeeks.com/2018/01/postgresql-open-liberty.html
postgresql
總結
以上是生活随笔為你收集整理的postgresql_PostgreSQL开放自由的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring Boot和Apache C
- 下一篇: jpa执行sql脚本_JPA persi