Announcements Portlet MySQL Setup

In order to setup MySQL as the database for the Announcements Portlet, you'll first need to add a new dependency to the pom.xml file. Something like this:

 <dependencies>
    ...
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>connector-java</artifactId>
            <version>5.1.6-bin</version>
            <type>jar</type>
        </dependency>
    ...
 </dependencies>

Create a new database for the portlet (in the example below the database is called portlets_announcements. Open the file datasource.properties in src/main/resources. Change it to reflect your database configuration, for example, the following would connect you to a MySQL 5.x server. You might be used to using "autoReconnect=true" on the driver.url string, but in newer versions of MySQL 5, this is deprecated in favor of using the validationQuery.

driver.class=com.mysql.jdbc.Driver
driver.url=jdbc:mysql://localhost/portlets_announcements
driver.username=your_username
driver.password=your_password
validationQuery=/* ping */
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
...

Now back in the same directory as the pom.xml file, run mvn install and you'll be alerted that the mysql-connector-java jar file is missing. Download the jar file from MySQL (http://dev.mysql.com/downloads/connector/j/5.1.html) and follow the instructions in the Maven error message to install it. Once installed, run mvn install again and the portlet will compile with your MySQL server as the datasource.