Skip to content

Instantly share code, notes, and snippets.

@enujo
enujo / web.xml
Created January 6, 2017 07:50
spring mvc insert
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
package com.tistory.luahius;
public class Math {
public int MyMath(int x, int y){
return x+y;
}
public static void main(String[] args){
Math m = new Math();
@enujo
enujo / pom.xml
Created January 13, 2017 04:30
Spring mySQL myBatis 의존성 주입
<!-- mysql connector 추가 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version>
</dependency>
<!-- 스프링에서 JDBC 사용을 위한 spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
@enujo
enujo / servlet-context.xml
Created January 13, 2017 04:39
transaction을 위한 빈추가
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
@enujo
enujo / LibraryNewdbNuser.sql
Last active February 3, 2017 02:40
Library DB생성, 사용자 계정 생성 및 권한 부여 SQL 생성문
-- DB 생성
CREATE DATEABASE library DEFAULT CHARSET euckr;;
-- 사용자 계정 생성 및 권한 부여
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON library.* TO 'userid'@'localhost' IDENTIFIED BY 'userpw';
@enujo
enujo / query.sql
Created January 24, 2017 07:08
테이블 명세서를 위한 쿼리문
-- mysql 테이블 형식 추출 쿼리
SELECT
t1.table_name, ORDINAL_POSITION, column_name 'Column Name', COLUMN_TYPE 'COLUMN TYPE', column_key 'Key',
case
when is_nullable = 'YES' THEN 'Y'
when is_nullable = 'NO' THEN 'N'
END AS 'Null able',
column_default 'Default Value', column_comment 'Comment',t1.table_comment,extra 'Extra'
FROM
@enujo
enujo / LibraryTable.sql
Created January 24, 2017 07:53
Library table SQL
-- 지역
CREATE TABLE region (
region_no INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
region_name VARCHAR (30) NOT NULL
)DEFAULT CHARSET=euckr COMMENT '지역';
-- 도서관
CREATE TABLE library(
library_no INT NOT NULL PRIMARY KEY COMMENT '도서관 일련번호',
region_no INT NOT NULL COMMENT '지역 번호',
@enujo
enujo / null_check.sql
Last active January 26, 2017 03:44
DBMS null check
-- MySQL null check
SELECT IFNULL(컬럼명,'치환값') 보여질컬럼명
FROM 테이블명;
-- MS-SQL null check
SELECT ISNULL(컬럼명,'치환값') 보여질컬럼명
FROM 테이블명;
-- ORACLE null check
SELECT NVL(컬럼명,'치환값') 보여질컬럼명
@enujo
enujo / insert_select.sql
Last active January 26, 2017 05:34
DBMS insert select
-- MySQL,MS-SQL
INSERT 테이블명(컬럼명)
SELECT 테이블명2.컬럼명
FROM 테이블명2
WHERE 조건
-- MS-SQL (INTO일 경우 테이블명 테이블이 자동 생성되며 값 insert)
SELECT 컬럼명
INTO 테이블명
@enujo
enujo / mapper.xml
Created February 2, 2017 06:54
insert in mapper
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">