Wednesday, September 06, 2006

Pointing Hibernate to MySql

Continuing on from my last post, we'll now try getting the crm sampel working with MySQL and Hibernate. Again, I'm going to try and keep this simple. Here's the steps.


1. Recreate the db in mysql. If you look in samples\web-inf\db\crm you will find a file called crm.script which has the sql statements you will need.

2. Make sure you have the mysql-jdbc-connector libraries. Put the .jar file in the samples\web-inf\lib folder.

3. Edit the HsqlServlet.java file in samples\web-inf\src\samples\crm as follows:

  • change the connection.driver_class to com.mysql.jdbc.Driver
  • change the connection.url to jdbc:mysql://127.0.0.1:3306/crm (assuming defaults)
  • change the connection.username and connection.password
  • change the dialect to org.hibernate.dialect.MySQLDialect
  • comment out the hbm2ddl.auto line

4. Compile the HsqlServlet.java file into samples\web-inf\classes.

5. Run FDS. Keep an eye out on the console for any errors.

6. Open the companyapp.mxml in a browser.

No comments: