Question

I use BoneCP in my Spring-based application.

<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
        <property name="driverClass" value="com.mysql.jdbc.Driver" />
        <property name="jdbcUrl" value="jdbc:mysql://ec2-23-21-211-???.compute-1.amazonaws.com:3306/?????" />
        <property name="username" value="*****"/>
        <property name="password" value="********"/>
        <property name="idleConnectionTestPeriod" value="60"/>
        <property name="idleMaxAge" value="240"/>
        <property name="maxConnectionsPerPartition" value="3"/>
        <property name="minConnectionsPerPartition" value="1"/>
        <property name="partitionCount" value="1"/>
        <property name="acquireIncrement" value="5"/>
        <property name="statementsCacheSize" value="100"/>
        <property name="releaseHelperThreads" value="3"/>
    </bean>

Is there any short value for jdbcURL?

Was it helpful?

Solution

You can inject it via environmental variable through the CloudBees SDK.

1.Inject the datasource and the following environmental variables via bees app:bind

With the CloudBees SDK:

bees app:bind -a appName -db dbName -as mydb

It will automatically inject a datasource and will create these three environmental variables:

   ${DATABASE_URL_DB}
   ${DATABASE_USERNAME_DB}
   ${DATABASE_PASSWORD_DB}

Please, be aware that you will use on this way one active connection for the maxActive: '20' by default on the Tomcat JDBC Connection Pool.

2.Enable PlaceHolder on Spring framework and mark system-properties-mode as "OVERRIDE".

<context:property-placeholder location="classpath:spring/data-access.properties" system-properties-mode="OVERRIDE"/>

Example here.

3.On your datasource.xml configuration file, then you could use something like this:

value= "jdbc:"+ ${DATABASE_URL_DB}

Be aware that the recommended way to get the datasource on CloudBees is always using JNDI.

In this way, you will use our own implementation of the datasource, so you don't have to write the username, the password or the URL of the database. Instead of all these lines, you can just replace all of them for this one:

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/mydb" resource-ref="true"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top