royclarkson / spring-rest-service-oauth

A simple OAuth protected REST service built with Spring Boot and Spring Security OAuth
Apache License 2.0
663 stars 339 forks source link

Connect This Project To Mysql #50

Open morteza57 opened 8 years ago

morteza57 commented 8 years ago

Hello my friends how can connect this project to Mysql database and create tables and read and write to that tables.

Eitol commented 8 years ago

Hola, se que no es MySQL, pero con esta BD en PostgreSQL pude hacer correr el proyecto, solo debes migrarla a MySQL

-- PostgreSQL database dump

-- Dumped from database version 9.1.21 -- Dumped by pg_dump version 9.1.21 -- Started on 2016-04-18 22:56:54 VET

SET statement_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; SET client_min_messages = warning;

-- TOC entry 1 (class 3079 OID 11645)

-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;

-- TOC entry 1882 (class 0 OID 0) -- Dependencies: 1

-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';

SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

-- TOC entry 165 (class 1259 OID 24616) -- Dependencies: 6

-- Name: role; Type: TABLE; Schema: public; Owner: postgres; Tablespace:

CREATE TABLE role ( id integer NOT NULL, name character(50) NOT NULL );

ALTER TABLE public.role OWNER TO postgres;

-- TOC entry 164 (class 1259 OID 24614) -- Dependencies: 165 6

-- Name: role_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres

CREATE SEQUENCE role_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;

ALTER TABLE public.role_id_seq OWNER TO postgres;

-- TOC entry 1883 (class 0 OID 0) -- Dependencies: 164

-- Name: role_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres

ALTER SEQUENCE role_id_seq OWNED BY role.id;

-- TOC entry 163 (class 1259 OID 24608) -- Dependencies: 6

-- Name: user; Type: TABLE; Schema: public; Owner: postgres; Tablespace:

CREATE TABLE "user" ( id integer NOT NULL, name character(50) NOT NULL, login character(50) NOT NULL, password character(50) NOT NULL );

ALTER TABLE public."user" OWNER TO postgres;

-- TOC entry 162 (class 1259 OID 24606) -- Dependencies: 163 6

-- Name: user_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres

CREATE SEQUENCE user_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1;

ALTER TABLE public.user_id_seq OWNER TO postgres;

-- TOC entry 1884 (class 0 OID 0) -- Dependencies: 162

-- Name: user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres

ALTER SEQUENCE user_id_seq OWNED BY "user".id;

-- TOC entry 166 (class 1259 OID 24622) -- Dependencies: 6

-- Name: user_role; Type: TABLE; Schema: public; Owner: postgres; Tablespace:

CREATE TABLE user_role ( user_id integer, role_id integer );

ALTER TABLE public.user_role OWNER TO postgres;

-- TOC entry 1762 (class 2604 OID 24619) -- Dependencies: 164 165 165

-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres

ALTER TABLE ONLY role ALTER COLUMN id SET DEFAULT nextval('role_id_seq'::regclass);

-- TOC entry 1761 (class 2604 OID 24611) -- Dependencies: 163 162 163

-- Name: id; Type: DEFAULT; Schema: public; Owner: postgres

ALTER TABLE ONLY "user" ALTER COLUMN id SET DEFAULT nextval('user_id_seq'::regclass);

-- TOC entry 1873 (class 0 OID 24616) -- Dependencies: 165 1875

-- Data for Name: role; Type: TABLE DATA; Schema: public; Owner: postgres

COPY role (id, name) FROM stdin; 1 ROLE_USER
2 ROLE_ADMIN
3 ROLE_GUEST
.

-- TOC entry 1885 (class 0 OID 0) -- Dependencies: 164

-- Name: role_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres

SELECT pg_catalog.setval('role_id_seq', 1, false);

-- TOC entry 1871 (class 0 OID 24608) -- Dependencies: 163 1875

-- Data for Name: user; Type: TABLE DATA; Schema: public; Owner: postgres

COPY "user" (id, name, login, password) FROM stdin; 1 Roy roy spring
2 Craig craig spring
3 Greg greg spring
.

-- TOC entry 1886 (class 0 OID 0) -- Dependencies: 162

-- Name: user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres

SELECT pg_catalog.setval('user_id_seq', 1, false);

-- TOC entry 1874 (class 0 OID 24622) -- Dependencies: 166 1875

-- Data for Name: user_role; Type: TABLE DATA; Schema: public; Owner: postgres

COPY user_role (user_id, role_id) FROM stdin; 1 1 1 2 2 1 3 1 .

-- TOC entry 1766 (class 2606 OID 24621) -- Dependencies: 165 165 1876

-- Name: role_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:

ALTER TABLE ONLY role ADD CONSTRAINT role_pkey PRIMARY KEY (id);

-- TOC entry 1764 (class 2606 OID 24613) -- Dependencies: 163 163 1876

-- Name: user_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace:

ALTER TABLE ONLY "user" ADD CONSTRAINT user_pkey PRIMARY KEY (id);

-- TOC entry 1768 (class 2606 OID 24630) -- Dependencies: 1765 166 165 1876

-- Name: user_role_role_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres

ALTER TABLE ONLY user_role ADD CONSTRAINT user_role_role_id_fkey FOREIGN KEY (role_id) REFERENCES role(id);

-- TOC entry 1767 (class 2606 OID 24625) -- Dependencies: 163 166 1763 1876

-- Name: user_role_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres

ALTER TABLE ONLY user_role ADD CONSTRAINT user_role_user_id_fkey FOREIGN KEY (user_id) REFERENCES "user"(id);

-- TOC entry 1881 (class 0 OID 0) -- Dependencies: 6

-- Name: public; Type: ACL; Schema: -; Owner: postgres

REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON SCHEMA public FROM postgres; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO PUBLIC;

-- Completed on 2016-04-18 22:56:54 VET

-- PostgreSQL database dump complete

morteza57 commented 8 years ago

Dear my friend,

First of all please write the messages in English, and i don't need to create tables and schema in database i need how to connect the sample project to database like Mysql,Thank you in advance.

0lexandr commented 8 years ago

Dear "Morteza57". I've used MySQL in this app https://github.com/Pivopil/spring-boot-oauth2-rest-service-password-encoding. Use code and properties from "rest" module to configure your app. All the best.