mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2026-02-19 04:01:12 +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
7
src/main/resources/db/hsqldb/dropTables.txt
Normal file
7
src/main/resources/db/hsqldb/dropTables.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
DROP TABLE visits;
|
||||
DROP TABLE pets;
|
||||
DROP TABLE owners;
|
||||
DROP TABLE types;
|
||||
DROP TABLE vet_specialties;
|
||||
DROP TABLE specialties;
|
||||
DROP TABLE vets;
|
||||
55
src/main/resources/db/hsqldb/initDB.txt
Normal file
55
src/main/resources/db/hsqldb/initDB.txt
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
CREATE TABLE vets (
|
||||
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
first_name VARCHAR(30),
|
||||
last_name VARCHAR(30)
|
||||
);
|
||||
CREATE INDEX vets_last_name ON vets(last_name);
|
||||
|
||||
CREATE TABLE specialties (
|
||||
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
name VARCHAR(80)
|
||||
);
|
||||
CREATE INDEX specialties_name ON specialties(name);
|
||||
|
||||
CREATE TABLE vet_specialties (
|
||||
vet_id INTEGER NOT NULL,
|
||||
specialty_id INTEGER NOT NULL
|
||||
);
|
||||
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 INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
name VARCHAR(80)
|
||||
);
|
||||
CREATE INDEX types_name ON types(name);
|
||||
|
||||
CREATE TABLE owners (
|
||||
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
first_name VARCHAR(30),
|
||||
last_name VARCHAR(30),
|
||||
address VARCHAR(255),
|
||||
city VARCHAR(80),
|
||||
telephone VARCHAR(20)
|
||||
);
|
||||
CREATE INDEX owners_last_name ON owners(last_name);
|
||||
|
||||
CREATE TABLE pets (
|
||||
id INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
name VARCHAR(30),
|
||||
birth_date DATE,
|
||||
type_id INTEGER NOT NULL,
|
||||
owner_id INTEGER NOT NULL
|
||||
);
|
||||
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 INTEGER NOT NULL IDENTITY PRIMARY KEY,
|
||||
pet_id INTEGER NOT NULL,
|
||||
visit_date DATE,
|
||||
description VARCHAR(255)
|
||||
);
|
||||
alter table visits add constraint fk_visits_pets foreign key (pet_id) references pets(id);
|
||||
CREATE INDEX visits_pet_id ON visits(pet_id);
|
||||
53
src/main/resources/db/hsqldb/populateDB.txt
Normal file
53
src/main/resources/db/hsqldb/populateDB.txt
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
INSERT INTO vets VALUES (1, 'James', 'Carter');
|
||||
INSERT INTO vets VALUES (2, 'Helen', 'Leary');
|
||||
INSERT INTO vets VALUES (3, 'Linda', 'Douglas');
|
||||
INSERT INTO vets VALUES (4, 'Rafael', 'Ortega');
|
||||
INSERT INTO vets VALUES (5, 'Henry', 'Stevens');
|
||||
INSERT INTO vets VALUES (6, 'Sharon', 'Jenkins');
|
||||
|
||||
INSERT INTO specialties VALUES (1, 'radiology');
|
||||
INSERT INTO specialties VALUES (2, 'surgery');
|
||||
INSERT INTO specialties VALUES (3, 'dentistry');
|
||||
|
||||
INSERT INTO vet_specialties VALUES (2, 1);
|
||||
INSERT INTO vet_specialties VALUES (3, 2);
|
||||
INSERT INTO vet_specialties VALUES (3, 3);
|
||||
INSERT INTO vet_specialties VALUES (4, 2);
|
||||
INSERT INTO vet_specialties VALUES (5, 1);
|
||||
|
||||
INSERT INTO types VALUES (1, 'cat');
|
||||
INSERT INTO types VALUES (2, 'dog');
|
||||
INSERT INTO types VALUES (3, 'lizard');
|
||||
INSERT INTO types VALUES (4, 'snake');
|
||||
INSERT INTO types VALUES (5, 'bird');
|
||||
INSERT INTO types VALUES (6, 'hamster');
|
||||
|
||||
INSERT INTO owners VALUES (1, 'George', 'Franklin', '110 W. Liberty St.', 'Madison', '6085551023');
|
||||
INSERT INTO owners VALUES (2, 'Betty', 'Davis', '638 Cardinal Ave.', 'Sun Prairie', '6085551749');
|
||||
INSERT INTO owners VALUES (3, 'Eduardo', 'Rodriquez', '2693 Commerce St.', 'McFarland', '6085558763');
|
||||
INSERT INTO owners VALUES (4, 'Harold', 'Davis', '563 Friendly St.', 'Windsor', '6085553198');
|
||||
INSERT INTO owners VALUES (5, 'Peter', 'McTavish', '2387 S. Fair Way', 'Madison', '6085552765');
|
||||
INSERT INTO owners VALUES (6, 'Jean', 'Coleman', '105 N. Lake St.', 'Monona', '6085552654');
|
||||
INSERT INTO owners VALUES (7, 'Jeff', 'Black', '1450 Oak Blvd.', 'Monona', '6085555387');
|
||||
INSERT INTO owners VALUES (8, 'Maria', 'Escobito', '345 Maple St.', 'Madison', '6085557683');
|
||||
INSERT INTO owners VALUES (9, 'David', 'Schroeder', '2749 Blackhawk Trail', 'Madison', '6085559435');
|
||||
INSERT INTO owners VALUES (10, 'Carlos', 'Estaban', '2335 Independence La.', 'Waunakee', '6085555487');
|
||||
|
||||
INSERT INTO pets VALUES (1, 'Leo', '2000-09-07', 1, 1);
|
||||
INSERT INTO pets VALUES (2, 'Basil', '2002-08-06', 6, 2);
|
||||
INSERT INTO pets VALUES (3, 'Rosy', '2001-04-17', 2, 3);
|
||||
INSERT INTO pets VALUES (4, 'Jewel', '2000-03-07', 2, 3);
|
||||
INSERT INTO pets VALUES (5, 'Iggy', '2000-11-30', 3, 4);
|
||||
INSERT INTO pets VALUES (6, 'George', '2000-01-20', 4, 5);
|
||||
INSERT INTO pets VALUES (7, 'Samantha', '1995-09-04', 1, 6);
|
||||
INSERT INTO pets VALUES (8, 'Max', '1995-09-04', 1, 6);
|
||||
INSERT INTO pets VALUES (9, 'Lucky', '1999-08-06', 5, 7);
|
||||
INSERT INTO pets VALUES (10, 'Mulligan', '1997-02-24', 2, 8);
|
||||
INSERT INTO pets VALUES (11, 'Freddy', '2000-03-09', 5, 9);
|
||||
INSERT INTO pets VALUES (12, 'Lucky', '2000-06-24', 2, 10);
|
||||
INSERT INTO pets VALUES (13, 'Sly', '2002-06-08', 1, 10);
|
||||
|
||||
INSERT INTO visits VALUES (1, 7, '1996-03-04', 'rabies shot');
|
||||
INSERT INTO visits VALUES (2, 8, '1996-03-04', 'rabies shot');
|
||||
INSERT INTO visits VALUES (3, 8, '1996-06-04', 'neutered');
|
||||
INSERT INTO visits VALUES (4, 7, '1996-09-04', 'spayed');
|
||||
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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue