From 300e4d72842dbd4fffc3abb2685a06f7701e2936 Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Fri, 23 Jan 2009 20:52:20 +0000 Subject: [PATCH] SPR-5429 Update Pet Clinic to use HSQL as an embedded database Removing support for running HSQL in stand-alone mode. Out of the box embedded HSQL and MySQL are supported. --- .../db/hsqldb/dropDB.txt | 7 -- .../db/hsqldb/initDB.txt | 55 -------------- .../db/hsqldb/manager.bat | 1 - .../db/hsqldb/manager.sh | 1 - .../db/hsqldb/petclinic.log | 0 .../db/hsqldb/petclinic.properties | 18 ----- .../db/hsqldb/petclinic.script | 71 ------------------- .../db/hsqldb/petclinic_tomcat_hsql.xml | 55 -------------- .../db/hsqldb/server.bat | 1 - .../db/hsqldb/server.properties | 1 - .../db/hsqldb/server.sh | 1 - .../readme.txt | 5 -- .../src/main/resources/jdbc.properties | 26 +------ 13 files changed, 3 insertions(+), 239 deletions(-) delete mode 100644 org.springframework.samples.petclinic/db/hsqldb/dropDB.txt delete mode 100644 org.springframework.samples.petclinic/db/hsqldb/initDB.txt delete mode 100644 org.springframework.samples.petclinic/db/hsqldb/manager.bat delete mode 100644 org.springframework.samples.petclinic/db/hsqldb/manager.sh delete mode 100644 org.springframework.samples.petclinic/db/hsqldb/petclinic.log delete mode 100644 org.springframework.samples.petclinic/db/hsqldb/petclinic.properties delete mode 100644 org.springframework.samples.petclinic/db/hsqldb/petclinic.script delete mode 100644 org.springframework.samples.petclinic/db/hsqldb/petclinic_tomcat_hsql.xml delete mode 100644 org.springframework.samples.petclinic/db/hsqldb/server.bat delete mode 100644 org.springframework.samples.petclinic/db/hsqldb/server.properties delete mode 100644 org.springframework.samples.petclinic/db/hsqldb/server.sh diff --git a/org.springframework.samples.petclinic/db/hsqldb/dropDB.txt b/org.springframework.samples.petclinic/db/hsqldb/dropDB.txt deleted file mode 100644 index 90ae6329f90..00000000000 --- a/org.springframework.samples.petclinic/db/hsqldb/dropDB.txt +++ /dev/null @@ -1,7 +0,0 @@ -DROP TABLE visits; -DROP TABLE pets; -DROP TABLE owners; -DROP TABLE types; -DROP TABLE vet_specialties; -DROP TABLE specialties; -DROP TABLE vets; diff --git a/org.springframework.samples.petclinic/db/hsqldb/initDB.txt b/org.springframework.samples.petclinic/db/hsqldb/initDB.txt deleted file mode 100644 index a75bfbbd86d..00000000000 --- a/org.springframework.samples.petclinic/db/hsqldb/initDB.txt +++ /dev/null @@ -1,55 +0,0 @@ -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); diff --git a/org.springframework.samples.petclinic/db/hsqldb/manager.bat b/org.springframework.samples.petclinic/db/hsqldb/manager.bat deleted file mode 100644 index 0631b09e3b3..00000000000 --- a/org.springframework.samples.petclinic/db/hsqldb/manager.bat +++ /dev/null @@ -1 +0,0 @@ -"%JAVA_HOME%\bin\java" -classpath ..\..\..\ivy-cache\repository\org.hsqldb\com.springsource.org.hsqldb\1.8.0.9\com.springsource.org.hsqldb-1.8.0.9.jar org.hsqldb.util.DatabaseManager diff --git a/org.springframework.samples.petclinic/db/hsqldb/manager.sh b/org.springframework.samples.petclinic/db/hsqldb/manager.sh deleted file mode 100644 index 20fb583d6a3..00000000000 --- a/org.springframework.samples.petclinic/db/hsqldb/manager.sh +++ /dev/null @@ -1 +0,0 @@ -java -classpath ../../../ivy-cache/repository/org.hsqldb/com.springsource.org.hsqldb/1.8.0.9/com.springsource.org.hsqldb-1.8.0.9.jar org.hsqldb.util.DatabaseManager diff --git a/org.springframework.samples.petclinic/db/hsqldb/petclinic.log b/org.springframework.samples.petclinic/db/hsqldb/petclinic.log deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/org.springframework.samples.petclinic/db/hsqldb/petclinic.properties b/org.springframework.samples.petclinic/db/hsqldb/petclinic.properties deleted file mode 100644 index e143515de26..00000000000 --- a/org.springframework.samples.petclinic/db/hsqldb/petclinic.properties +++ /dev/null @@ -1,18 +0,0 @@ -#HSQL Database Engine -#Mon Jan 09 09:39:15 GMT 2006 -hsqldb.script_format=0 -runtime.gc_interval=0 -sql.enforce_strict_size=false -hsqldb.cache_size_scale=10 -readonly=false -hsqldb.nio_data_file=true -hsqldb.cache_scale=14 -version=1.8.0 -hsqldb.default_table_type=memory -hsqldb.cache_file_scale=1 -sql.compare_in_locale=false -hsqldb.log_size=200 -modified=yes -hsqldb.cache_version=1.7.0 -hsqldb.original_version=1.7.1 -hsqldb.compatible_version=1.8.0 diff --git a/org.springframework.samples.petclinic/db/hsqldb/petclinic.script b/org.springframework.samples.petclinic/db/hsqldb/petclinic.script deleted file mode 100644 index 8ce9564131d..00000000000 --- a/org.springframework.samples.petclinic/db/hsqldb/petclinic.script +++ /dev/null @@ -1,71 +0,0 @@ -CREATE SCHEMA PUBLIC AUTHORIZATION DBA -CREATE MEMORY TABLE VETS(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,FIRST_NAME VARCHAR(30),LAST_NAME VARCHAR(30)) -CREATE INDEX VETS_LAST_NAME ON VETS(LAST_NAME) -CREATE MEMORY TABLE SPECIALTIES(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,NAME VARCHAR(80)) -CREATE INDEX SPECIALTIES_NAME ON SPECIALTIES(NAME) -CREATE MEMORY TABLE VET_SPECIALTIES(VET_ID INTEGER NOT NULL,SPECIALTY_ID INTEGER NOT NULL,CONSTRAINT FK_VET_SPECIALTIES_VETS FOREIGN KEY(VET_ID) REFERENCES VETS(ID),CONSTRAINT FK_VET_SPECIALTIES_SPECIALTIES FOREIGN KEY(SPECIALTY_ID) REFERENCES SPECIALTIES(ID)) -CREATE MEMORY TABLE TYPES(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,NAME VARCHAR(80)) -CREATE INDEX TYPES_NAME ON TYPES(NAME) -CREATE MEMORY TABLE OWNERS(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL 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 MEMORY TABLE PETS(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,NAME VARCHAR(30),BIRTH_DATE DATE,TYPE_ID INTEGER NOT NULL,OWNER_ID INTEGER NOT NULL,CONSTRAINT FK_PETS_OWNERS FOREIGN KEY(OWNER_ID) REFERENCES OWNERS(ID),CONSTRAINT FK_PETS_TYPES FOREIGN KEY(TYPE_ID) REFERENCES TYPES(ID)) -CREATE INDEX PETS_NAME ON PETS(NAME) -CREATE MEMORY TABLE VISITS(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,PET_ID INTEGER NOT NULL,VISIT_DATE DATE,DESCRIPTION VARCHAR(255),CONSTRAINT FK_VISITS_PETS FOREIGN KEY(PET_ID) REFERENCES PETS(ID) ON DELETE CASCADE) -CREATE INDEX VISITS_PET_ID ON VISITS(PET_ID) -ALTER TABLE VETS ALTER COLUMN ID RESTART WITH 7 -ALTER TABLE SPECIALTIES ALTER COLUMN ID RESTART WITH 4 -ALTER TABLE TYPES ALTER COLUMN ID RESTART WITH 7 -ALTER TABLE OWNERS ALTER COLUMN ID RESTART WITH 11 -ALTER TABLE PETS ALTER COLUMN ID RESTART WITH 14 -ALTER TABLE VISITS ALTER COLUMN ID RESTART WITH 5 -CREATE USER SA PASSWORD "" -GRANT DBA TO SA -SET WRITE_DELAY 60 -SET SCHEMA PUBLIC -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') diff --git a/org.springframework.samples.petclinic/db/hsqldb/petclinic_tomcat_hsql.xml b/org.springframework.samples.petclinic/db/hsqldb/petclinic_tomcat_hsql.xml deleted file mode 100644 index 27c1f713586..00000000000 --- a/org.springframework.samples.petclinic/db/hsqldb/petclinic_tomcat_hsql.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - factory - org.apache.commons.dbcp.BasicDataSourceFactory - - - - driverClassName - org.hsqldb.jdbcDriver - - - url - jdbc:hsqldb:hsql://localhost:9001 - - - username - sa - - - - maxActive - 50 - - - maxIdle - 10 - - - maxWait - 10000 - - - removeAbandoned - true - - - removeAbandonedTimeout - 60 - - - logAbandoned - true - - - - - diff --git a/org.springframework.samples.petclinic/db/hsqldb/server.bat b/org.springframework.samples.petclinic/db/hsqldb/server.bat deleted file mode 100644 index bdb94f1d20b..00000000000 --- a/org.springframework.samples.petclinic/db/hsqldb/server.bat +++ /dev/null @@ -1 +0,0 @@ -"%JAVA_HOME%\bin\java" -classpath ..\..\..\ivy-cache\repository\org.hsqldb\com.springsource.org.hsqldb\1.8.0.9\com.springsource.org.hsqldb-1.8.0.9.jar org.hsqldb.Server -database petclinic diff --git a/org.springframework.samples.petclinic/db/hsqldb/server.properties b/org.springframework.samples.petclinic/db/hsqldb/server.properties deleted file mode 100644 index 1572908fa66..00000000000 --- a/org.springframework.samples.petclinic/db/hsqldb/server.properties +++ /dev/null @@ -1 +0,0 @@ -server.trace=true diff --git a/org.springframework.samples.petclinic/db/hsqldb/server.sh b/org.springframework.samples.petclinic/db/hsqldb/server.sh deleted file mode 100644 index 0021e37f558..00000000000 --- a/org.springframework.samples.petclinic/db/hsqldb/server.sh +++ /dev/null @@ -1 +0,0 @@ -java -classpath ../../../ivy-cache/repository/org.hsqldb/com.springsource.org.hsqldb/1.8.0.9/com.springsource.org.hsqldb-1.8.0.9.jar org.hsqldb.Server -database petclinic diff --git a/org.springframework.samples.petclinic/readme.txt b/org.springframework.samples.petclinic/readme.txt index 840a0ceefa6..8ccb9d6660a 100644 --- a/org.springframework.samples.petclinic/readme.txt +++ b/org.springframework.samples.petclinic/readme.txt @@ -64,11 +64,6 @@ included in this sample application. By default, an embedded HSQL instance in configured. No other steps are necessary to get the data source up and running. -To use HSQL as a remote database, open "src/jdbc.properties", comment out all -properties in the "HSQL Embedded Settings" section, uncomment all properties in -the "HSQL Settings" section. Start the remote HSQLDB instance in the -"db/hsqldb" directory, for example using "server.bat". - For MySQL, you'll need to use the corresponding schema and SQL scripts in the "db/mysql" subdirectory. Follow the steps outlined in "db/mysql/petclinic_db_setup_mysql.txt" for explicit details. diff --git a/org.springframework.samples.petclinic/src/main/resources/jdbc.properties b/org.springframework.samples.petclinic/src/main/resources/jdbc.properties index 9c423e51be6..f27b7002d7d 100644 --- a/org.springframework.samples.petclinic/src/main/resources/jdbc.properties +++ b/org.springframework.samples.petclinic/src/main/resources/jdbc.properties @@ -4,6 +4,7 @@ # various application context XML files (e.g., "applicationContext-*.xml"). # Targeted at system administrators, to avoid touching the context XML files. + #------------------------------------------------------------------------------- # Common Settings @@ -11,8 +12,9 @@ hibernate.generate_statistics=true hibernate.show_sql=true jpa.showSql=true + #------------------------------------------------------------------------------- -# HSQL Embedded Settings +# HSQL Settings jdbc.driverClassName=org.hsqldb.jdbcDriver jdbc.url=jdbc:hsqldb:mem:petclinic @@ -34,28 +36,6 @@ jpa.databasePlatform=org.springframework.samples.petclinic.toplink.EssentialsHSQ # Property that determines which database to use with an AbstractJpaVendorAdapter jpa.database=HSQL -#------------------------------------------------------------------------------- -# HSQL Settings - -#jdbc.driverClassName=org.hsqldb.jdbcDriver -#jdbc.url=jdbc:hsqldb:hsql://localhost:9001 -#jdbc.username=sa -#jdbc.password= - -# Properties that control the population of schema and data for a new data source -#jdbc.populate=false -#jdbc.schemaLocation= -#jdbc.dataLocation= - -# Property that determines which Hibernate dialect to use -# (only applied with "applicationContext-hibernate.xml") -#hibernate.dialect=org.hibernate.dialect.HSQLDialect - -# Property that determines which JPA DatabasePlatform to use with TopLink Essentials -#jpa.databasePlatform=org.springframework.samples.petclinic.toplink.EssentialsHSQLPlatformWithNativeSequence - -# Property that determines which database to use with an AbstractJpaVendorAdapter -#jpa.database=HSQL #------------------------------------------------------------------------------- # MySQL Settings