Page 1 of 1

Loading Items in External Postgres Database

Posted: Mon Aug 22, 2011 12:11 pm
by partyk1d24
So I changed the application context for demo (and entity) to point at an external DB. I see the actual tables get created, however, I don't see any products on the demo site. If I go under Admin, I also see no products and all of the categories appear to be orphaned (store is the only category). If I try to add a product I get the following error...

Code: Select all

ADD

Error while processing RPC request:

Problem adding new entity : org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update


Code: Select all

<bean id="webDS" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
      <property name="driverClassName" value="org.postgresql.Driver" />
      <property name="url" value="jdbc:postgresql://localhost/broadleafcommerce" />
      <property name="username" value="broadleaf" />
      <property name="password" value="broadleaf" />
   </bean>


Any clue what I might be doing wrong? Where is the catalina.out if I use $>ant jetty-demo?

Thanks

Jackie

Re: Loading Items in External Postgres Database

Posted: Mon Aug 22, 2011 12:39 pm
by jefffischer
Did you remember to change the hibernate dialect in the persistence-demo.xml? This is according to the persistence documentation:

http://www.broadleafcommerce.org/conflu ... figuration

Re: Loading Items in External Postgres Database

Posted: Mon Aug 22, 2011 1:03 pm
by partyk1d24
I don't think so, where is that file located? I am assuming I also have to change the connection in the build.xml as well? Found that too. Why do I have to change the connection string in so many places? Wouldn't it be easier to use Maven Profiles or some such and system properties?

Jackie

Re: Loading Items in External Postgres Database

Posted: Mon Aug 22, 2011 1:09 pm
by partyk1d24
I found this...

Code: Select all

<list>
                <value>classpath*:/META-INF/persistence-demo.xml</value>
            </list>


In the context but I don't see that file, does it get generated or live in one of the other sub projects?

Re: Loading Items in External Postgres Database

Posted: Mon Aug 22, 2011 1:13 pm
by jefffischer
I'm not sure what you're referring to in build.xml. If you're talking about the HSQL stuff in build.xml, you can ignore this because you don't need to start and stop this database since you're using postgres. persistence-demo.xml is located at site/BroadleafCommerceDemo/src/main/resources/META-INF/persistence-demo.xml.

Re: Loading Items in External Postgres Database

Posted: Mon Aug 22, 2011 4:37 pm
by partyk1d24
Do I need to drop the DB and recreate it? Didn't work if not. Here is my section of the .properties...

Code: Select all

<persistence-unit name="blPU" transaction-type="RESOURCE_LOCAL">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <non-jta-data-source>jdbc/web</non-jta-data-source>
      <class>com.other.domain.OtherProductImpl</class>
      <exclude-unlisted-classes/>
      <properties>
            <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
            <property name="hibernate.show_sql" value="false"/>
            <property name="hibernate.hbm2ddl.import_files" value="/import_standard.sql"/>
        </properties>
   </persistence-unit>


Am I missing something here?

Re: Loading Items in External Postgres Database

Posted: Mon Aug 22, 2011 4:46 pm
by partyk1d24
Tried to drop and readd database, not luck. Do I still need the parameters at the end of the JDBC url?

Re: Loading Items in External Postgres Database

Posted: Mon Aug 22, 2011 4:57 pm
by jefffischer
based on the jdbc url you posted above, you will need to create a database in your running postgres instance called "broadleafcommerce".

you may need to do a 'mvn install' on your modified BroadleafCommerceDemo module

you will need to watch the console during your server startup - there may be some point at which the sql inside import_standard.sql is incompatible with postgres (it was written for HSQL) - the log will report to you the line number in import_standard.sql if there is a problem.

Re: Loading Items in External Postgres Database

Posted: Mon Aug 22, 2011 5:09 pm
by partyk1d24
I will look into running the SQL manually, but for now I tried adding that param and looks like no dice.

Now when I try to go somewhere I get...

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (FATAL: database "broadleafcommerce;ifexists=true" does not exist)

So looks like no dice on that end.

Thank you so much for all your help BTW, it really is helping!

Re: Loading Items in External Postgres Database

Posted: Mon Aug 22, 2011 5:11 pm
by jefffischer
Definitely don't put the ";ifexists=true" at the end of the jdbc url - this is an HSQL only thing.