Page 1 of 1

change datasource

Posted: Tue Apr 12, 2011 6:34 am
by giannisapi
Hi,

Another question which I think it will be useful to any new comer like is how to change datasource from hsql to mysql.
Is there a central file which when altered the whole application will be using mysql (or other database). If not, could you please give me a list of the the files that need to be altered..


Thanks in advance,
giannis

Re: change datasource

Posted: Wed Apr 20, 2011 4:43 am
by jefffischer
This topic is covered here:

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

If you're looking to change the datasource for the demo, then you'll need the project source so you can make changes and rebuild the demonstration war. The key files in the demo to change are:

applicationContext-demo.xml
persistence-demo.xml

There is a datasource definition in applicationContext-demo.xml (webDS) that currently uses the HSQL driver. You would need to change this to whatever driver you want to use (MYSQL for example). Note, you would need to include your new driver as a dependency in the pom.xml for the demo as well.

In persistence-demo.xml, you would need to change the hibernate.dialect property to the required value for your database platform as well.

Again, these instructions apply to the demo, you're real-world implementation would likely be different. For example, in the real world, you would likely retrieve the datasource through jndi lookup from the container.