From dae0ea18aae3e98808727fe570c59e7dad0e429e Mon Sep 17 00:00:00 2001
From: Rhys Evans <EvansRM17@cardiff.ac.uk>
Date: Wed, 29 Nov 2023 19:27:47 +0000
Subject: [PATCH] Trying to get sql to work, mock databases work here, not sure
 why, pair programming/ code review dev RN PO RE

---
 build.gradle                              |   4 ++--
 clientUsers.db                            | Bin 0 -> 8192 bytes
 src/main/resources/application.properties |   5 ++++-
 src/main/resources/templates/data.sql     |   2 ++
 src/main/resources/templates/schema.sql   |   6 ++++++
 5 files changed, 14 insertions(+), 3 deletions(-)
 create mode 100644 clientUsers.db
 create mode 100644 src/main/resources/templates/data.sql
 create mode 100644 src/main/resources/templates/schema.sql

diff --git a/build.gradle b/build.gradle
index 57fb1434..e83ee87c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -30,8 +30,8 @@ dependencies {
 	annotationProcessor 'org.projectlombok:lombok'
 	testImplementation 'org.springframework.boot:spring-boot-starter-test'
 	implementation 'org.springframework.boot:spring-boot-starter-validation'
-//	implementation 'org.springframework.boot:spring-boot-starter-jdbc'
-//	implementation 'org.mariadb.jdbc:mariadb-java-client:2.1.2'
+	implementation 'org.springframework.boot:spring-boot-starter-jdbc'
+	implementation 'org.mariadb.jdbc:mariadb-java-client:2.1.2'
 }
 
 tasks.named('bootBuildImage') {
diff --git a/clientUsers.db b/clientUsers.db
new file mode 100644
index 0000000000000000000000000000000000000000..0310bc11880ed24271bf932342496a0213c4e889
GIT binary patch
literal 8192
zcmeIuJqp4=5QgDNVk_nXfho1I@d8Fk7Z5cUh`7q4`5|nR!drPj6G$LkdU*$iZ<!sY
zc&_KvI-`%ODRQSf3B~hduPP!z*Z$Dnkc%$I>SuEm$oBME_FJLI>N~g2KLQ9KfB*sr
zAb<b@2q1s}0tie5(kSw*%WrQ}R?ZZ)Ysd7Dmn6;-&Ei9v=s4B2y{j#qd74J+#uj<g
f>dUm7$xWUJAb<b@2q1s}0tg_000Iag@TUSlZ-yaU

literal 0
HcmV?d00001

diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 8b137891..d7f55564 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1 +1,4 @@
-
+spring.datasource.url=jdbc:mariadb://localhost:3306/rhys
+spring.datasource.username=root
+spring.datasource.password=comsc
+spring.sql.init.mode=always
diff --git a/src/main/resources/templates/data.sql b/src/main/resources/templates/data.sql
new file mode 100644
index 00000000..6b7393c4
--- /dev/null
+++ b/src/main/resources/templates/data.sql
@@ -0,0 +1,2 @@
+delete from rhys;
+insert into rhys (name, tel_number) values ( 'Ian', '111');
\ No newline at end of file
diff --git a/src/main/resources/templates/schema.sql b/src/main/resources/templates/schema.sql
new file mode 100644
index 00000000..0338f622
--- /dev/null
+++ b/src/main/resources/templates/schema.sql
@@ -0,0 +1,6 @@
+drop table if exists rhys;
+create table if not exists rhys (
+    id bigint auto_increment primary key,
+    name varchar(128),
+    tel_number varchar(128)
+) engine=InnoDB;
\ No newline at end of file
-- 
GitLab