728x90

Limit 연산자를 이용하면 쿼리 결과 개수를 제한할 수 있다.

1
select * from 테이블명 Limit 개수(정수);



예) cookie_sales 테이블에서 first_name별로 그룹을 만들어 sales컬럼의 합계가 가장 높은 순으로 
     출력하되, 2개까지만 출력한다.

1
2
3
4
select first_name, sum(sales) from cookie_sales
group by first_name
order by sum(sales) desc
Limit 2;

결과

 first_namesales 
 Britney107.91 
 Paris98.23 





Limit의 조금 다른 사용법

아래처럼 두 개의 정수가 들어간다면 완전히 다른 의미가 된다. 

Limit 0, 4 
                  0은 시작할 레코드의 번호이다. (SQL은 0이 처음)
                  4는 반환할 결과의 수이다. 


예를 들어 음악 챠트에서 20위에서 30위까지 보고 싶다고 하면 
Limit 19,10 으로 하면 된다~



출처: http://warmz.tistory.com/259

Posted by 앗뜨거
,
728x90



스크립트 부분
1
2
3
4
5
6
7
function onlyNumber()
        {
            if ((event.keyCode < 48) || (event.keyCode > 57))
            {
                event.returnValue = false;
            }
        }




사용할부분


1
<input type="text" id="txtMobile2" size="4" onkeypress="onlyNumber()"/>



onkeypress 에 넣어주면 키보드 입력시 숫자만 들어가고 나머지는 입력이 되지 않는다.

Posted by 앗뜨거
,
728x90

Oracle에서 제공하는 SQL Developer를 사용할 경우


기본 Date 출력 포맷은 RR/MM/DD 로되어있다 ( 예> 12/11/01 )

Date 포맷을 시간단위까지 보고 싶다면 어떻게 해야 할까?

SQL Developer 환경설정을 통해서 적용 할 수 있다

도구 ( Tools ) -> 환경설정 ( Preference ) 로 들어간 후

왼쪽 리스트에서 데이터베이스 ( Database ) -> NLS 로 들어간다

오른쪽 설정 창에 날짜 형식 (Date Format) 이 있을 것이다

여기서 바꿔주면 된다




이 출력 포맷은 SELECT문으로 출력되는 Column 뿐만 아니라

테이블을 Export할 때도 적용된다



출처 : aslike.egloos.com/2976365


Posted by 앗뜨거
,
728x90

Eclipse의 자동빌드는 수시로 이러나기 때문에

Workspace에 Project / 소스가 많을 경우 이클립스의 속도가 저하되는 경우가 많다.

그러므로 소스 작성시에는 자동빌드(오토빌드)를 꺼두고
 
작성 소스을 완료하고 실행시에 빌드를 시킨다

설정하기

Project - Bulid Automatically


수동빌드

Ctrl + B
or
Project - Bulid All



출처 : http://ehbread.tistory.com/11

Posted by 앗뜨거
,
728x90

<img src="한글.jpg" ......../> 로 태그를 쓰면 




이런식으로 이미지가 깨져서 나오게 된다.





해결방법은 여러가지가 있겠으나


내가 이해하기 쉽고 간단하게 하는법이 있어서 쓰게됐다.



나같은경우는 



여기 서버를 열어서


이부분을 찾습니다. 끝부분에 URIEncoding="utf-8" 을넣어주면

 


 해결완료!!!



그런데 혹시 이것도 해결이 안된다면 하나더 추가 해주면 됩니다.


DTO.java  파일에서 


그림을 저장하는 setter 의 인코딩을 해주면되요


예를들면 이런식으로


1
2
3
4
5
6
7
8
9
10
11
12
13
public void setG_image1(String g_image1) 
    {
        try 
        {
            this.g_image1 = URLEncoder.encode(g_image1,"utf-8");
        } 
        catch (UnsupportedEncodingException e) 
        {
            e.printStackTrace();
        }
        this.g_image1 = g_image1;
    }
 


이렇게 둘다 해주면 거의 될꺼에요 혹시 안되면 서버를 완전히 종료후 클린시켜주고 다시 실핼시킨후 브라우져에서 F5를 한번눌러보세요~

Posted by 앗뜨거
,
728x90

MyBatis는 iBATIS의 새로운 버전으로 국내에서 가장 많이 사용되는 ORM Framework[각주:1] 중 하나이다. MyBatis는 문서화가 잘 되어 있다고 하지만 막상 실전에 적용시키기에는 이전 버전인 iBATIS에 비해 예제가 부족한 듯하여 자료 정리겸 레퍼런스를 만들어 볼까 한다.

우선 MyBatis를 설정하고 간단한 예제를 만들어 본 다음, Spring 3로 Bean을 등록하는 예제로 확장시켜 볼 예정이다.

본 예제는 다음과 같은 개발환경하에서 작성되었다.

  • Eclipse Java EE IDE (Juno)
    • PropertiesEditor (by Sou Miyazaki)
  • Java SE 6
  • MyBatis-3.1.1
  • JUnit 4

1. MySQL Table


1
2
3
4
5
6
7
CREATE TABLE user (
    id INT(5) NOT NULL PRIMARY KEY AUTO_INCREMENT,
    username VARCHAR(16) NOT NULL,
    password VARCHAR(16) NOT NULL,
    level INT(2) NOT NULL DEFAULT '0',
    reg_date DATE NOT NULL
);

2. Configuration


development.properties


1
2
3
4
url=jdbc:mysql://localhost/development?characterEncoding=utf-8
driver=com.mysql.jdbc.Driver
user=development
pass=test123



mysql-config.xml


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<p><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
<configuration>
    <properties resource="exercise/mybatis3/persistence/development.properties"/>
     
    <settings>
        <setting name="defaultExecutorType" value="REUSE"/>
        <setting name="useGeneratedKeys" value="true"/>
    </settings>
     
    <typeAliases>
    <!-- Type Aliases List -->   
    </typeAliases>
     
    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <dataSource type="JNDI">
                <property name="initial_context" value="java:comp/env" />
                <property name="data_source" value="jdbc/insure"/>
            </dataSource>
        </environment>
         
        <environment id="testing">
            <transactionManager type="MANAGED">
                <property name="closeConnection" value="false"/>
            </transactionManager>
            <dataSource type="POOLED">
                <property name="driver" value="${driver}" />
                <property name="url" value="${url}" />
                <property name="username" value="${user}" />
                <property name="password" value="${pass}" />
            </dataSource>
        </environment>
    </environments>
     
    <mappers>
    <!-- Mapper List -->
    </mappers>
</configuration></p>

3. SQL Mapper (CRUD)

UserMapper.xml


1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="exercise.mybatis3.persistence.UserMapper">
    <insert id="add" parameterType="User"
            useGeneratedKeys="true" keyProperty="id">
        INSERT INTO user (username, password, level, reg_date)
        VALUES (#{username}, #{password}, 1, NOW())
    </insert>
     
    <select id="count" resultType="int">
        SELECT COUNT(*) FROM user
    </select>
</mapper>

UserMapper.java


1
2
3
4
5
6
7
8
9
10
package exercise.mybatis3.persistence;
 
import exercise.mybatis3.domain.User;
 
public interface UserMapper {
     
    public void add(User user);
     
    public int count();
}

4. Domain Object

User.java


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package exercise.mybatis3.domain;
 
import java.io.Serializable;
 
public class User implements Serializable {
 
    private static final long serialVersionUID = 1L;
     
    private Integer id;
    private String username;
    private String password;
    private Integer level;
    private String regDate;
 
    public User() {
        // TODO Auto-generated constructor stub
    }
     
    public User(String username, String password) {
        this.username = username;
        this.password = password;
    }
 
    public Integer getId() {
        return id;
    }
 
    public void setId(Integer id) {
        this.id = id;
    }
 
    public String getUsername() {
        return username;
    }
 
    public void setUsername(String username) {
        this.username = username;
    }
 
    public String getPassword() {
        return password;
    }
 
    public void setPassword(String password) {
        this.password = password;
    }
 
    public Integer getLevel() {
        return level;
    }
 
    public void setLevel(Integer level) {
        this.level = level;
    }
 
    public String getRegDate() {
        return regDate;
    }
 
    public void setRegDate(String regDate) {
        this.regDate = regDate;
    }
 
}

5. Unit Test (CRUD)

TestUserMapper.java


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package exercise.mybatis3.test;
 
import static org.junit.Assert.assertThat;
import static org.hamcrest.CoreMatchers.is;
 
import java.io.Reader;
 
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
 
import exercise.mybatis3.domain.User;
import exercise.mybatis3.persistence.UserMapper;
 
public class TestUserMapper {
    static SqlSessionFactory sf;
    User user;
 
    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        String resource = "exercise/mybatis3/persistence/mybatis-config.xml";
        Reader reader = Resources.getResourceAsReader(resource);
        sf = new SqlSessionFactoryBuilder().build(reader, "testing");
         
    }
     
    @Before
    public void setUp() {
        user = new User("user1", "1234");
    }
 
    @Test
    public void testAdd() {
        SqlSession session = sf.openSession();
         
        try {
            UserMapper mapper = session.getMapper(UserMapper.class);
             
            mapper.add(user);
            assertThat(1, is(mapper.count()));
        } finally {
            session.close();
        }
    }
 
}

출처: http://jeongsam.net/259


'프로그래밍 > ibatis' 카테고리의 다른 글

[MyBatis] $ 과 # 차이점  (0) 2014.11.18
iBatis 복수 parameter넘기는법  (0) 2014.11.18
[스크랩]resultMap, resultClass, parameterClass  (0) 2014.10.14
Posted by 앗뜨거
,
728x90

org.apache.jasper.JasperException: /includee.jspf(1,2) Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html; charset=UTF-8, new: text/html; charset=utf-8)


jsp 모듈화작업시 이런 오류가 나온다면 


나같은경우는 모든페이지를 확인해서  UTF-8 로 되어있는것을 utf-8로 바꾸어줬다.. 대소문자를 구별하다니 못찾을뻔...

Posted by 앗뜨거
,
728x90

1.위시캣 http://www.wishket.com/

2. 프리누리 http://freenuri.co.kr/

3. 프리모아 http://freemoa.net/

Posted by 앗뜨거
,
728x90



체크박스를 보면 위에 "아이디 기억하기와같이 정렬이 되야되는데

부트스트랩3.2 를 예전처럼




1
2
3
4
5
6
7
8
                        <div class="form-group">
                            <div class="col-md-offset-2 col-md-10">
                                <div class="checkbox">
                                    <input type="checkbox" id="chkRememberMe" name="chkRememberMe" />
                                    <label for="chkRememberMe">암호 저장</label>
                                </div>
                            </div>
                        </div>


이런식으로 <div class="checkbox" >  안에 input과 label 을 따로 해주면 밑에 암호저장과 같이 왼쪽으로 밀리고 글씨도 밀린다.


해결방법은




1
2
3
4
5
6
7
8
9
                        <div class="form-group">
                            <div class="col-md-offset-2 col-md-10">
                                <div class="checkbox">
                                    <label>
                                        <input type="checkbox" id="chkRememberMe" name="chkRememberMe" />아이디 기억하기
                                    </label>
                                </div>
                            </div>
                        </div>



이런식으로 체크박스로 묶어준다음에 

라벨로 인풋을 묶어주면 해결된다. 

'프로그래밍 > BootStrap' 카테고리의 다른 글

부트스트랩 2.x to 3.2  (0) 2014.10.05
Posted by 앗뜨거
,
728x90



   

패럴랙스 관심있어서 찾아보니 쉬운예제 소개해드립니다.

이미지만 바꾸면 심플한 효과를 볼수있습니다.

   

원본링크 : https://ihatetomatoes.net/simple-parallax-scrolling-tutorial/




   


   

   



   



   

이부분 에다가 이미지를 넣어도되고 문구변경해도되고 ~~

   

여기서 조금씩 수정해나가면 패럴랙스 이해하는데 도움이 될듯싶습니다

물론 코드 설명도 잘되어있고요 ~

 

------------------------------------------------------------------------ 

 

그 외 parallax library들 ~



   


   

이런스타일도좋은데

http://www.webdingo.net/zoo/


   



   

요론스타일의 디자인도 이쁘네요

   

http://www.apple.com/imac-with-retina/

   



   


   

애플도 패럴랙스!

이쁜듯!

[출처] Parallax sample 코드 |작성자 세줄


Posted by 앗뜨거
,