如何创建一个jta-data-source文件?

时间:2017-02-22 19:04:25

标签: java-ee jta glassfish-4.1

我正在使用Glassfish 4.1。 我希望我的persistence.xml文件如下所示:

2017-02-22 13:47:12.010901 NotKarltonBanks[1537:425489] <FIRAnalytics/DEBUG> Logging event: origin, name, params: app, select_content, {
    "_o" = app;
    "_sc" = MoreViewController;
    "_si" = "-3358907490504482271";
    "content_type" = button;
    "item_id" = "id-1";
    "item_name" = "Tapped Not Karlton Keyboard Tutorial Button";
}
2017-02-22 13:47:12.012 NotKarltonBanks[1537:] <FIRAnalytics/DEBUG> Logging event: origin, name, params: app, select_content, {
        "_o" = app;
        "_sc" = MoreViewController;
        "_si" = "-3358907490504482271";
        "content_type" = button;
        "item_id" = "id-1";
        "item_name" = "Tapped Not Karlton Keyboard Tutorial Button";
    }
2017-02-22 13:47:12.019693 NotKarltonBanks[1537:425489] <FIRAnalytics/DEBUG> Debug mode is enabled. Marking event as debug and real-time. Event name, parameters: select_content, {
    "_dbg" = 1;
    "_o" = app;
    "_r" = 1;
    "_sc" = MoreViewController;
    "_si" = "-3358907490504482271";
    "content_type" = button;
    "item_id" = "id-1";
    "item_name" = "Tapped Not Karlton Keyboard Tutorial Button";
}
2017-02-22 13:47:12.021 NotKarltonBanks[1537:] <FIRAnalytics/DEBUG> Debug mode is enabled. Marking event as debug and real-time. Event name, parameters: select_content, {
        "_dbg" = 1;
        "_o" = app;
        "_r" = 1;
        "_sc" = MoreViewController;
        "_si" = "-3358907490504482271";
        "content_type" = button;
        "item_id" = "id-1";
        "item_name" = "Tapped Not Karlton Keyboard Tutorial Button";
    }
2017-02-22 13:47:12.048798 NotKarltonBanks[1537:425305] current page 0
2017-02-22 13:47:12.054340 NotKarltonBanks[1537:425305] current page 0
2017-02-22 13:47:12.101634 NotKarltonBanks[1537:425489] <FIRAnalytics/DEBUG> Event logged. Event name, event params: select_content, {
    "_dbg" = 1;
    "_o" = app;
    "_r" = 1;
    "_sc" = MoreViewController;
    "_si" = "-3358907490504482271";
    "content_type" = button;
    "item_id" = "id-1";
    "item_name" = "Tapped Not Karlton Keyboard Tutorial Button";
}

我不知道如何或在何处创建&#39; PostgreDS&#39;文件。

2 个答案:

答案 0 :(得分:1)

您需要在glassfish-resources.xml文件中描述您的数据源,并将此文件放在webapp/WEB-INF文件夹下。

看看这个article

答案 1 :(得分:0)

只是为了完整性mexes_s回答。这是我最终配置PostgreSQL连接的文件。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN"
    "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-connection-pool 
        allow-non-component-callers="false" 
        associate-with-thread="false" 
        connection-creation-retry-attempts="0" 
        connection-creation-retry-interval-in-seconds="10" 
        connection-leak-reclaim="false" 
        connection-leak-timeout-in-seconds="0" 
        connection-validation-method="auto-commit" 
        datasource-classname="org.postgresql.ds.PGPoolingDataSource" 
        fail-all-connections="false" 
        idle-timeout-in-seconds="300" 
        is-connection-validation-required="false" 
        is-isolation-level-guaranteed="true" 
        lazy-connection-association="false" 
        lazy-connection-enlistment="false" 
        match-connections="false" 
        max-connection-usage-count="0" 
        max-pool-size="32" 
        max-wait-time-in-millis="60000" 
        name="java:app/jdbc/PostgreSQLPool" 
        non-transactional-connections="false" 
        pool-resize-quantity="2" 
        res-type="javax.sql.ConnectionPoolDataSource" 
        statement-timeout-in-seconds="-1" 
        steady-pool-size="8" 
        validate-atmost-once-period-in-seconds="0" 
        wrap-jdbc-objects="false">    
    <property name="user" value="postgres"/>
    <property name="portNumber" value="5432"/>
    <property name="password" value="postgres"/>
    <property name="serverName" value="localhost"/>
    <property name="databaseName" value="PostgreSQLDB"/>
    <property name="URL" value="jdbc:postgresql://localhost:5432/PostgreSQLDB"/>
    <property name="driverClass" value="org.postgresql.ds.PGPoolingDataSource"/>
    <property name="connectionAttributes" value=";create=true"/>
</jdbc-connection-pool>
<jdbc-resource 
        enabled="true" 
        jndi-name="java:app/jdbc/PostgreSQLDS" 
        object-type="user" 
        pool-name="java:app/jdbc/PostgreSQLPool"/>
</resources>