Database Reference
In-Depth Information
Spring/XML
The following code allows Spring XML connection. It configures BasicDataSource
through the DATABASE_URL variable and can be used with Hibernate, JPA, and others.
The following is just a code sample to help you understand the concept:
<bean class="java.net.URI" id="connectionParams">
<constructor-arg
value="#{systemEnvironment['DATABASE_URL']}"/>
</bean>
<bean class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close" id="dataSource">
<property name="driverClassName"
value="org.postgresql.Driver" />
<property name="username"
value="#{@connectionParams.getUserInfo().split(':')[0]}" />
<property name="password"
value="#{@connectionParams.getUserInfo().split(':')[1]}" />
<property name="url" value="#{'jdbc:postgresql://' +
@connectionParams.getHost() + @connectionParams.getPath()}"
/>
</bean>
Search WWH ::




Custom Search