mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-05-28 14:19:38 +00:00
SPR-6447
+ moved db files around + moved JPA/AOP META-INF/ files into the webapp classpath
This commit is contained in:
parent
d109fdd2f5
commit
50b87ef75f
8 changed files with 132 additions and 6 deletions
3
src/main/resources/db/mysql/createDB.txt
Normal file
3
src/main/resources/db/mysql/createDB.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
CREATE DATABASE petclinic;
|
||||
|
||||
GRANT ALL PRIVILEGES ON petclinic.* TO pc@localhost IDENTIFIED BY 'pc';
|
1
src/main/resources/db/mysql/dropDB.txt
Normal file
1
src/main/resources/db/mysql/dropDB.txt
Normal file
|
@ -0,0 +1 @@
|
|||
DROP DATABASE petclinic;
|
58
src/main/resources/db/mysql/initDB.txt
Normal file
58
src/main/resources/db/mysql/initDB.txt
Normal file
|
@ -0,0 +1,58 @@
|
|||
USE petclinic;
|
||||
|
||||
CREATE TABLE vets (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
first_name VARCHAR(30),
|
||||
last_name VARCHAR(30),
|
||||
INDEX(last_name)
|
||||
) engine=InnoDB;
|
||||
|
||||
CREATE TABLE specialties (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(80),
|
||||
INDEX(name)
|
||||
) engine=InnoDB;
|
||||
|
||||
CREATE TABLE vet_specialties (
|
||||
vet_id INT(4) UNSIGNED NOT NULL,
|
||||
specialty_id INT(4) UNSIGNED NOT NULL
|
||||
) engine=InnoDB;
|
||||
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_vets FOREIGN KEY (vet_id) REFERENCES vets(id);
|
||||
ALTER TABLE vet_specialties ADD CONSTRAINT fk_vet_specialties_specialties FOREIGN KEY (specialty_id) REFERENCES specialties(id);
|
||||
|
||||
CREATE TABLE types (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(80),
|
||||
INDEX(name)
|
||||
) engine=InnoDB;
|
||||
|
||||
CREATE TABLE owners (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
first_name VARCHAR(30),
|
||||
last_name VARCHAR(30),
|
||||
address VARCHAR(255),
|
||||
city VARCHAR(80),
|
||||
telephone VARCHAR(20),
|
||||
INDEX(last_name)
|
||||
) engine=InnoDB;
|
||||
|
||||
CREATE TABLE pets (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(30),
|
||||
birth_date DATE,
|
||||
type_id INT(4) UNSIGNED NOT NULL,
|
||||
owner_id INT(4) UNSIGNED NOT NULL,
|
||||
INDEX(name)
|
||||
) engine=InnoDB;
|
||||
ALTER TABLE pets ADD CONSTRAINT fk_pets_owners FOREIGN KEY (owner_id) REFERENCES owners(id);
|
||||
ALTER TABLE pets ADD CONSTRAINT fk_pets_types FOREIGN KEY (type_id) REFERENCES types(id);
|
||||
CREATE INDEX pets_name ON pets(name);
|
||||
|
||||
CREATE TABLE visits (
|
||||
id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
pet_id INT(4) UNSIGNED NOT NULL,
|
||||
visit_date DATE,
|
||||
description VARCHAR(255),
|
||||
INDEX(pet_id)
|
||||
) engine=InnoDB;
|
||||
ALTER TABLE visits ADD CONSTRAINT fk_visits_pets FOREIGN KEY (pet_id) REFERENCES pets(id);
|
64
src/main/resources/db/mysql/petclinic_tomcat_mysql.xml
Normal file
64
src/main/resources/db/mysql/petclinic_tomcat_mysql.xml
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Context path="/petclinic" docBase="petclinic" debug="4" reloadable="true">
|
||||
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_petclinic_log." suffix=".txt" timestamp="true"/>
|
||||
|
||||
<!-- Define a database connection pool for MYSQL -->
|
||||
<Resource name="jdbc/petclinicMYSQL" auth="Container" type="javax.sql.DataSource"/>
|
||||
<ResourceParams name="jdbc/petclinicMYSQL">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<name>driverClassName</name>
|
||||
<value>org.gjt.mm.mysql.Driver</value>
|
||||
</parameter>
|
||||
<!--
|
||||
The JDBC connection url for connecting to your MySQL dB.
|
||||
The autoReconnect=true argument to the url makes sure that the
|
||||
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
|
||||
connection. mysqld by default closes idle connections after 8 hours.
|
||||
-->
|
||||
<parameter>
|
||||
<name>url</name>
|
||||
<value>jdbc:mysql://localhost:3306/petclinic?autoReconnect=true</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>username</name>
|
||||
<value>pc</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>password</name>
|
||||
<value>pc</value>
|
||||
</parameter>
|
||||
|
||||
<parameter>
|
||||
<name>maxActive</name>
|
||||
<value>50</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxIdle</name>
|
||||
<value>10</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxWait</name>
|
||||
<value>10000</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>removeAbandoned</name>
|
||||
<value>true</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>removeAbandonedTimeout</name>
|
||||
<value>60</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>logAbandoned</name>
|
||||
<value>true</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
|
||||
</Context>
|
|
@ -23,9 +23,9 @@ jdbc.password=
|
|||
|
||||
# Properties that control the population of schema and data for a new data source
|
||||
jdbc.populate=true
|
||||
jdbc.schemaLocation=classpath:hsqldb/initDB.txt
|
||||
jdbc.dataLocation=classpath:hsqldb/populateDB.txt
|
||||
jdbc.dropLocation=classpath:hsqldb/dropTables.txt
|
||||
jdbc.schemaLocation=classpath:db/hsqldb/initDB.txt
|
||||
jdbc.dataLocation=classpath:db/hsqldb/populateDB.txt
|
||||
jdbc.dropLocation=classpath:db/hsqldb/dropTables.txt
|
||||
|
||||
# Property that determines which Hibernate dialect to use
|
||||
# (only applied with "applicationContext-hibernate.xml")
|
||||
|
@ -48,9 +48,9 @@ jpa.database=HSQL
|
|||
|
||||
# Properties that control the population of schema and data for a new data source
|
||||
#jdbc.populate=false
|
||||
#jdbc.schemaLocation=
|
||||
#jdbc.dataLocation=
|
||||
#jdbc.dropLocation=
|
||||
#jdbc.schemaLocation=classpath:db/mysql/initDB.txt
|
||||
#jdbc.dataLocation=classpath:db/mysql/populateDB.txt
|
||||
#jdbc.dropLocation=classpath:db/mysql/dropTables.txt
|
||||
|
||||
# Property that determines which Hibernate dialect to use
|
||||
# (only applied with "applicationContext-hibernate.xml")
|
||||
|
|
Loading…
Reference in a new issue