如何在glassfish-resources.xml动态更改jdbc-connection-pool属性?

时间:2018-01-15 17:59:59

标签: java postgresql jdbc ejb glassfish-4.1

基本上我有两个运行我的应用程序的环境,我在AWS上使用预配置的Docker环境来部署我的应用程序。因此,每当我需要将新版本部署到任何环境时,它都会通过glassfish 4.1.1获取glassfish-resources.xml的连接属性。需要在glassfish-resources.xml中指定dataBase的属性。环境。有没有办法动态设置这个属性,比如在服务器上设置一些系统属性并在运行时获取它们来设置该环境的正确数据库?
顺便说一下,我在AWS文档中找不到如何远程配置JNDI glassfish-resources.xml example:

<?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.apache.derby.jdbc.ClientDataSource" 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="derby_net_demodb_appPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
        <property name="serverName" value="localhost"/>
        <property name="portNumber" value="1527"/>
        <property name="databaseName" value="demodb"/>
        <property name="User" value="app"/>
        <property name="Password" value="app"/>
        <property name="connectionAttributes" value=";create=true" />
        <property name="URL" value="jdbc:derby://localhost:1527/demodb;create=true"/>
        <property name="driverClass" value="org.apache.derby.jdbc.ClientDriver"/>
    </jdbc-connection-pool>
    <jdbc-resource enabled="true" jndi-name="java:app/jdbc/demodb" object-type="user" pool-name="derby_net_demodb_appPool"/>
</resources> 

0 个答案:

没有答案