I am using Spring Roo 1.2 and changed my database connection from mysql to postgres. I did this by excuting “persistence setup” in the Roo shell and also set the parameters in the file database.properties. As final step I’ve included the jdbc driver for postgres as dependency in pom.xml.
When executing “mvn clean jetty:run” I get following response:
2012-02-20 14:31:15,465 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - schema export unsuccessful
java.lang.UnsupportedOperationException: Not supported by BasicDataSource
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1062)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:68)
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:263)
at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:219)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:372)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:257)
What does this mean? Is schema export for Postgres not supported or do I have an configuration problem?
This is clearly a configuration problem. Take a look at the BasicDataSource source code, the exception is thrown because
BasicDataSourcedoes not supportgetConnection(String user, String pass)but onlygetConnection(). Sousernameandpasswordmust be set/configured before you callgetConnection().Hope that helps.