lundi 29 septembre 2014

Java Spring Heroku Template Connect to Local Database


Vote count:

0




I pulled the Heroku Spring template; however, I have been unable to connect the application to my local postgress DB. I am utilizing eclipse and have set an environment variable inside my run configuration to my local db url (there is no password set for the database):


DATABASE_URL = postgresql://username@localhost/mydb.


I've looked through the Heroku tutorials, is there a step I'm missing? My applicationContext.xml beans are as follows:



<beans profile="prod">
<bean class="java.net.URI" id="dbUrl">
<constructor-arg value="#{systemEnvironment['DATABASE_URL']}"/>
</bean>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="url" value="#{ 'jdbc:postgresql://' + @dbUrl.getHost() + ':' + @dbUrl.getPort() + @dbUrl.getPath() }"/>
<property name="username" value="#{ @dbUrl.getUserInfo().split(':')[0] }"/>
<property name="password" value="#{ @dbUrl.getUserInfo().split(':')[1] }"/>
</bean>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- change this to 'verify' before running as a production app -->
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
</beans>


asked 1 min ago







Java Spring Heroku Template Connect to Local Database

Aucun commentaire:

Enregistrer un commentaire