0

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?

Sandah Aung
  • 6,156
  • 15
  • 56
  • 98

1 Answers1

2

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"/>
felix
  • 511
  • 2
  • 3
  • Thanks for your answer. It's really helpful. Btw, isn't there any way you could do that without using the cloudbees sdk? – Sandah Aung Jan 13 '14 at 10:44
  • AFAIK it is an enhancement we are working on. We always recommend to use CloudBees. It is the way in which you can have a full control on the runtime environment. – felix Jan 13 '14 at 11:58
  • Cloudbees SDK is great but sometimes we have to work with machines which don't have the SDK installed. Downloading the SDK is quite a task when you have slow connections and that's when you start to wonder if there is any way you could accomplish things without the SDK. – Sandah Aung Jan 13 '14 at 13:45
  • 1
    This feature is not available at this moment. However, AFAIK it is something we are already working on. – felix Jan 14 '14 at 10:21