From cb0504ee976720d6759b91b747ea4cd88f9ba9ab Mon Sep 17 00:00:00 2001
From: Antoine Rey <antoine.rey@free.fr>
Date: Tue, 13 Oct 2015 08:32:15 +0200
Subject: [PATCH] #92 add some comments to switch from HSQLDB to MySQL

---
 pom.xml                                       |  9 +++++++-
 readme.md                                     | 13 ++++++++++++
 src/main/resources/db_readme.txt              | 13 ------------
 .../resources/spring/data-access.properties   | 21 +++++++------------
 4 files changed, 28 insertions(+), 28 deletions(-)
 delete mode 100644 src/main/resources/db_readme.txt

diff --git a/pom.xml b/pom.xml
index 2ffe282..3e56f09 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,6 +31,8 @@
 		<jodatime-jsptags.version>1.1.1</jodatime-jsptags.version>
 		<jadira-usertype-core.version>3.2.0.GA</jadira-usertype-core.version>
 
+		<!-- MySql -->
+		<mysql-driver.version>5.1.36</mysql-driver.version>
 
 		<!-- Web dependencies -->
 		<webjars-bootstrap.version>2.3.0</webjars-bootstrap.version>
@@ -189,7 +191,12 @@
 		</dependency>
 
 		<!-- For MySql only -->
-		<!-- <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> -->
+		<!--dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+			<version>${mysql-driver.version}</version>
+		</dependency-->
+
 		<!-- HIBERNATE -->
 		<dependency>
 			<groupId>org.hibernate</groupId>
diff --git a/readme.md b/readme.md
index a314398..8c84871 100644
--- a/readme.md
+++ b/readme.md
@@ -15,6 +15,19 @@ You can then access petclinic here: http://localhost:9966/petclinic/
 ## In case you find a bug/suggested improvement for Spring Petclinic
 Our issue tracker is available here: https://github.com/spring-projects/spring-petclinic/issues
 
+
+## Database configuration
+
+In its default configuration, Petclinic uses an in-memory database (HSQLDB) which
+gets populated at startup with data. A similar setup is provided for MySql in case a persistent database configuration is needed.
+Note that whenever the database type is changed, the data-access.properties file needs to be updated and the mysql-connector-java artifact from the pom.xml needs to be uncommented.
+
+You may start a MySql database with docker:
+
+```
+docker run -e MYSQL_ROOT_PASSWORD=petclinic -e MYSQL_DATABASE=petclinic -p 3306:3306 mysql:5.7.8
+```
+
 ## Working with Petclinic in Eclipse/STS
 
 ### prerequisites
diff --git a/src/main/resources/db_readme.txt b/src/main/resources/db_readme.txt
deleted file mode 100644
index 68e3f24..0000000
--- a/src/main/resources/db_readme.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-================================================================================
-===        Spring PetClinic sample application - Database Configuration      ===
-================================================================================
-
-@author Costin Leau
-
---------------------------------------------------------------------------------
-
-In its default configuration, Petclinic uses an in-memory database (HSQLDB) which
-gets populated at startup with data. A similar setup is provided for Mysql in case
-a persistent database configuration is needed.
-Note that whenever the database type is changed, the data-access.properties file needs to
-be updated.
diff --git a/src/main/resources/spring/data-access.properties b/src/main/resources/spring/data-access.properties
index c1cc3ce..e154d81 100644
--- a/src/main/resources/spring/data-access.properties
+++ b/src/main/resources/spring/data-access.properties
@@ -4,6 +4,12 @@
 # various application context XML files (e.g., "applicationContext-*.xml").
 # Targeted at system administrators, to avoid touching the context XML files.
 
+# Properties that control the population of schema and data for a new data source
+jdbc.initLocation=classpath:db/hsqldb/initDB.sql
+jdbc.dataLocation=classpath:db/hsqldb/populateDB.sql
+
+jpa.showSql=true
+
 #-------------------------------------------------------------------------------
 # HSQL Settings
 
@@ -12,14 +18,9 @@ jdbc.url=jdbc:hsqldb:mem:petclinic
 jdbc.username=sa
 jdbc.password=
 
-# Properties that control the population of schema and data for a new data source
-jdbc.initLocation=classpath:db/hsqldb/initDB.sql
-jdbc.dataLocation=classpath:db/hsqldb/populateDB.sql
-
 # Property that determines which database to use with an AbstractJpaVendorAdapter
 jpa.database=HSQL
 
-jpa.showSql=true
 
 #-------------------------------------------------------------------------------
 # MySQL Settings
@@ -27,15 +28,7 @@ jpa.showSql=true
 #jdbc.driverClassName=com.mysql.jdbc.Driver
 #jdbc.url=jdbc:mysql://localhost:3306/petclinic
 #jdbc.username=root
-#jdbc.password=
-
-# Properties that control the population of schema and data for a new data source
-#jdbc.initLocation=classpath:db/mysql/initDB.sql
-#jdbc.dataLocation=classpath:db/mysql/populateDB.sql
-
-# Property that determines which Hibernate dialect to use
-# (only applied with "applicationContext-hibernate.xml")
-#hibernate.dialect=org.hibernate.dialect.MySQLDialect
+#jdbc.password=petclinic
 
 # Property that determines which database to use with an AbstractJpaVendorAdapter
 #jpa.database=MYSQL
-- 
GitLab