How to change jdbc-connection-pool properties dynamically at glassfish-resources.xml?

Refresh

April 2019

Views

492 time

1

Basically I have two enviroments which run my Application, I use the preconfigured Docker enviroment on AWS to deploy my applications. So, it gets the connection properties by the glassfish-resources.xml, with Glassfish 4.1.1, everytime I need to deploy a new version to any enviroment It is needed to especify the properties of the dataBase in glassfish-resources.xml of that enviroment. Is there a way to set this properties dynamically, like set some System Properties on the server and get them in runtime to set the correct database of that enviroment ?
By the way, I could't find at the AWS documentation how to configure JNDI remotely
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 answers