Let's say we have a table team_person as below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
+======+===========+
| team |    person |
+======+===========+
|   A  |      John |
+------+-----------+
|   B  |     Smith |
+------+-----------+
|   A  |    Walter |
+------+-----------+
|   A  |     Louis |
+------+-----------+
|   C  | Elizabeth |
+------+-----------+
|   B  |     Wayne |
+------+-----------+
 
 
CREATE TABLE team_person AS SELECT 'A' team, 'John' person
UNION ALL  SELECT 'B' team,  'Smith' person
UNION ALL  SELECT 'A' team,  'Walter' person
UNION ALL  SELECT 'A' team,  'Louis' person
UNION ALL  SELECT 'C' team,  'Elizabeth' person
UNION ALL  SELECT 'B' team,  'Wayne' person;
cs

 

To select the table team_person with additional row_number column, either

1
2
SELECT @row_no := @row_no+1 AS row_number, team, person
FROM team_person, (SELECT @row_no := 0) t;
cs

* rownum 초기화 : (SELECT @row_no := 0) t;

 

OR

1
2
3
SET @row_no := 0;
SELECT  @row_no := @row_no + 1 AS row_number, team, person
FROM team_person;
cs

 

will output the result below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
+============+======+===========+
| row_number | team |    person |
+============+======+===========+
|          1 |   A  |      John |
+------------+------+-----------+
|          2 |   B  |     Smith |
+------------+------+-----------+
|          3 |   A  |    Walter |
+------------+------+-----------+
|          4 |   A  |     Louis |
+------------+------+-----------+
|          5 |   C  | Elizabeth |
+------------+------+-----------+
|          6 |   B  |     Wayne |
+------------+------+-----------+
cs

 

Finally, if we want to get the row_number group by column team

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
SELECT @row_no := IF(@prev_val = t.team, @row_no + 11) AS row_number
   ,@prev_val := t.team AS team
   ,t.person  
FROM team_person t,
  (SELECT @row_no := 0) x,
  (SELECT @prev_val := '') y
ORDER BY t.team ASC,t.person DESC; 
 
+============+======+===========+
| row_number | team |    person |
+============+======+===========+
|          1 |   A  |    Walter |
+------------+------+-----------+
|          2 |   A  |     Louis |
+------------+------+-----------+
|          3 |   A  |      John |
+------------+------+-----------+
|          1 |   B  |     Wayne |
+------------+------+-----------+
|          2 |   B  |     Smith |
+------------+------+-----------+
|          1 |   C  | Elizabeth |
+------------+------+-----------+
cs

 

출처 : riptutorial.com/mysql/example/19572/row-number-and-group-by-using-variables-in-select-statement

 

MySQL - Row Number and Group By using variables in Select Statement | mysql Tutorial

mysql documentation: Row Number and Group By using variables in Select Statement

riptutorial.com

developer-jjun.tistory.com/23

 

[MySQL] ROWNUM을 사용하여 번호매기기

MySQL에서 Oracle처럼 ROWNUM 사용법 SET구문을 사용하여 ROWNUM 값을 초기화 후 조회 SET @rownum:=0; SELECT @rownum:=@rownum+1, b.* FROM buyingboard b WHERE절에서 초기화 SELECT @rownum:=@rownum+1, b.*..

developer-jjun.tistory.com

 

 

Posted by 셋부터넷
,

highcharts 작업시 y축 중간라인의 텍스트가 보이지 않는문제 해결

1
2
3
4
5
6
7
Highcharts.wrap(Highcharts.Axis.prototype, 'getPlotLinePath', function(proceed) {
    var path = proceed.apply(this, Array.prototype.slice.call(arguments, 1));
    if (path) {
        path.flat = false;
    }
    return path;
});
cs

 

출처 : stackoverflow.com/questions/52621676/labels-are-not-rendering-for-plotlines-highcharts

 

Labels are not rendering for plotLines highcharts

I'm trying to render plotLines on Highcharts. But somehow I'm not able to render labels on plotLines. Here is the code snippet: var chart = new Highcharts.Chart({ chart: { ren...

stackoverflow.com

 

Posted by 셋부터넷
,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SELECT 
    DATE_FORMAT(m1, '%Y-%m') AS standardDate
FROM(
    SELECT 
        ('2020-01-11' - INTERVAL DAYOFMONTH('2020-01-11')-1 DAY) +INTERVAL m MONTH as m1
    FROM(
        SELECT @rownum:=@rownum+1 as m FROM
        (SELECT 1 union SELECT 2 union SELECT 3 union SELECT 4) t1,
        (SELECT 1 union SELECT 2 union SELECT 3 union SELECT 4) t2,
        (SELECT 1 union SELECT 2 union SELECT 3 union SELECT 4) t3,
        (SELECT 1 union SELECT 2 union SELECT 3 union SELECT 4) t4,
        (SELECT @rownum:=-1) t0
    ) d1
) d2 
WHERE m1 <= '2020-09-30' 
ORDER BY m1
cs

 

참고 : stackoverrun.com/ko/q/4011597

 

mysql에서 두 날짜 사이의 월 목록을 얻는 방법

mysql에서 두 날짜 사이의 월 목록을 가져 왔습니다. For Example:My Input is From date 23-01-2013 To Date 01-04-2014 Output Should be Jan 2013, Feb 2013, March 2013, . . . Jan 2014, Feb 2014, Mar 2014, Apr ...

stackoverrun.com

 

 

Posted by 셋부터넷
,

예제)

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
65
66
67
function(chartData) {
    Highcharts.chart('monitoringDonutChart', {
        credits: {
            enabled: false,
            position: {
                align: 'center',
                verticalAlign: 'middle'
            }
        },
        chart: {
            height: 250,
            width: 300,
            marginTop:  null,
            margin: null,
            animation: true,
            events: {
                load: function() {
                    var chart = this,
                    value = 0;
                    chart.series[0].yData.forEach(function(point, index) {
                        if(index == 0){
                            value += point;
                        }
                    });
                    
                    //파이챠트 중간에 텍스트 추가 후 상,하 센터정렬
                    chart.renderer.text(value, nullnull, chart.resetZoom, {
                        }).attr({
                           align: 'center',
                           verticalAlign: 'middle'
                        }).add().css({fontSize: '20px'}).align({
                           align: 'center',
                           verticalAlign: 'middle',
                           x: 0,
                           y: 0
                        }, falsenull);
                    
                }
            }
        },
        title: { 
            enabled: false,
            useHTML:true,
            text: null,
            verticalAlign: 'bottom'
        },
        plotOptions: {
            pie: {
                dataLabels: {
                    enabled: false
                },
                animation: false,
                showInLegend: true
            },
        },
        legend: {
            enabled: false
        },
        series: [{
            name'사용량',
            type: 'pie',
            innerSize: '75%',
            colors: ['#ffcc00''#c0c0c0'],
            data: chartData
        }, ],
    });
}
cs

 

참고)

- 도넛형태 : stackoverflow.com/questions/54434360/aligning-labels-in-highchart-donut

 

Aligning labels in highchart donut

I'm trying to make a highchart donut with a legend on the side, I'm really struggling to get the data labels to be more centered. At the moment each of them are in a different place, an image of

stackoverflow.com

- 중간에 텍스트삽입 : stackoverflow.com/questions/38072913/how-to-add-text-via-chart-renderer-text-in-highcharts

 

How to add text via chart.renderer.text in Highcharts?

I have succeeded adding additional text to my charts, like here. This, I achieved through adding a "function(chart)" to my "var chart = new Highcharts.Chart" $.get('xxx.csv', function(data) { ...

stackoverflow.com

 

- 가운데 정렬 : stackoverflow.com/questions/22310677/add-buttons-in-chart-of-highcharts-at-runtime

 

Add buttons in chart of Highcharts at runtime

I need to add some custom buttons (with onclick events), without overwrite the exporting buttons value, 'cause I wanna include new buttons without lost the custom buttons previously defined in cha...

stackoverflow.com

 

 

Posted by 셋부터넷
,

어느날 아래와 같은 구조를  가진 테이블을

 idx

area1 

area2 

area3 

area4 

area5 

 1

 10

20 

30 

40 

50 

 2

 11

21 

31 

41 

51 

 

 

아래와 같이 변경 해야 하는 경우가 닥치고 말았다

no

position 

value 

 1

 area1

 10

 1

 area2

 20

 1

 area3

 30

 1

 area4

 40

 1

 area5

 50

 2

 area1

 11

 2

 area2

 21

 2

 area3

 31

 2

 area4

 41

 2

 area5

 51

 

해결책 :

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
SELECT
    `no`,
    CASE 
        WHEN x=1 THEN 'area1'
        WHEN x=2 THEN 'area2'
        WHEN x=3 THEN 'area3'
        WHEN x=4 THEN 'area4'
        WHEN x=5 THEN 'area5'
    END `position`,
 
    CASE 
        WHEN x=1 THEN area1
        WHEN x=2 THEN area2
        WHEN x=3 THEN area3
        WHEN x=4 THEN area4
        WHEN x=5 THEN area5
    END `value
FROM (
    select * from default_data a,
    (
        select 1 AS x
        union all select 2 AS x
        union all select 3 AS x
        union all select 4 AS x
        union all select 5 AS x
    ) b
)
ORDER BY `NO`, `NUMBERS` ASC;
cs

 

[출처] Mysql 가로 컬럼 형태를 세로 rows 형태 로 변경|작성자 RS

Posted by 셋부터넷
,

Spring Security 설정 후 로그인을 해보면 아이디나 비밀번호가 틀려도 모두 BadCredentialException만 발생해서 두 가지 에러상황을 따로 처리할 수 없다. 해당 이슈를 구분할 수 있는 setHideUserNotFoundException설정이 기본 true로 설정되어있어 그렇다고한다. 더 강한 보안을 위해서 그렇다고 하는데 잘 이해가 안간다... 

 

암튼 이 설정값은 AuthenticationProvider 생성 시에 false로 수정할 수 있다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
@Bean
public DaoAuthenticationProvider daoAuthenticationProvider() {
    DaoAuthenticationProvider bean = new DaoAuthenticationProvider();
    bean.setHideUserNotFoundExceptions(false);
    bean.setUserDetailsService(userDetailsService);
    bean.setPasswordEncoder(passwordEncoder());
    
    return bean;
}
 
@Override 
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.authenticationProvider(this.daoAuthenticationProvider());
}
cs

Security Config 설정파일에서 AuthenticationProvider 생성 시 해당 값을 false로 지정한 뒤 적용한다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@Override
public void onAuthenticationFailure(
    HttpServletRequest request, 
    HttpServletResponse response, 
    AuthenticationException e) throws IOException, ServletException {
 
    String sErrMsg = "";
    if (e instanceof UsernameNotFoundException) {
        sErrMsg = "존재하지 않는 사용자입니다.";
    } else if (e instanceof BadCredentialsException) {
        sErrMsg = "비밀번호가 틀립니다.";
    } else {
        sErrMsg = "기타 인증오류입니다.";
    }
    
    ...
}
cs

AuthenticationFailureHandler를 구현한 핸들러에서 UsernameNotFoundException을 처리할 수 있다.

 

참고)

cyr9210.github.io/2019/09/30/Security/usernamenotfound/

 

인증 시, UsernameNotfoundException 발생 안함 문제(BadCredentials Exception만 발생)

SpringSecurityDebug인증 시, UsernameNotfoundException 발생 안함 문제(BadCredentials Exception만 발생)

cyr9210.github.io

www.programmersought.com/article/8509702354/

 

2019-01-10 springboot + spring-security The error message when logging in is "Bad Credential" instead of specific information...

In the background, if the username is incorrectly logged in, there is a specific error exception message returned. But in the front-end interface, I only saw "Bad Credential" instead of specific error messages. Keep track of the code and find the problem h

www.programmersought.com

codevang.tistory.com/268

 

스프링 Security_로그인_로그인 실패 대응 로직 [3/9]

- Develop OS : Windows10 Ent, 64bit - WEB/WAS Server : Tomcat v9.0 - DBMS : MySQL 5.7.29 for Linux (Docker) - Language : JAVA 1.8 (JDK 1.8) - Framwork : Spring 3.1.1 Release - Build Tool : Maven 3.6..

codevang.tistory.com

 

Posted by 셋부터넷
,

MySQL에서 특정날짜 사이의 날짜 목록 모두 가져오기

1
2
3
4
5
6
7
8
9
select * from 
(select adddate('2010-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date from
 (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0,
 (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1,
 (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2,
 (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3,
 (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v
where selected_date 
between '2018-09-10' and '2018-10-31'
cs

 

 

참고 : stackoverflow.com/questions/9295616/how-to-get-list-of-dates-between-two-dates-in-mysql-select-query

 

How to get list of dates between two dates in mysql select query

I want list of dates lies between two dates by select query. For example: If i give '2012-02-10' and '2012-02-15' I need the result. date ---------- 2012-02-10 2012-02-11 2012-02-12 2012-0...

stackoverflow.com

 

 

Posted by 셋부터넷
,

Eclipse사용 중 특정 프로젝트의 pom.xml에서 첫문단 <?xml version="1.0" encoding="UTF-8"?> 오류발생 시 아래와 같이 처리

 

1. m2e 커넥터 설치

참고 : download.eclipse.org/m2e-wtp/releases/1.4/

 

Eclipse software repository | The Eclipse Foundation

The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 360 open source projects, including runtimes, tools and frameworks.

download.eclipse.org

또는

2. maven-jar-plugin 다운그레이드

1
2
3
4
<properties>
    <!-- ... -->
    <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>
cs

pom.xml에 추가

참고 : stackoverflow.com/questions/56455851/maven-pom-xml-problem-unknown-error-at-top-line-xml-version-1-0-encoding

 

Maven POM.xml problem - Unknown error at top line ( )

I am setting up a project in STS with Spring starter project and added required dependencies like spring security and JSP. But the top line of pom file throwing an error as Unknown Can anybody he...

stackoverflow.com

 

 

 

Posted by 셋부터넷
,

sing Git and the Eclipse IDE, you have a series of commits in your branch history, but need to back up to an earlier version. The Git Reset feature is a powerful tool with just a whiff of danger, and is accessible with just a couple clicks in Eclipse.

In Eclipse, switch to the History view. In my example it shows a series of 3 changes, 3 separate committed versions of the Person file. After commit 6d5ef3e, the HEAD (shown), Index, and Working Directory all have the same version, Person 3.0.

 

 

Right-click on any of the commits to show the context menu, and select Reset to show a sub-menu with 3 options: Soft, Mixed and Hard. These options affect which of git's 3 sets of files are Reset.

 

 

Before proceeding, a brief reminder that Git has 3 different sets of the files.

First is the HEAD, which is everything that is safely committed into the Git repository.

 

Second is the Index, which are the files as they will look in the HEAD once you do the next commit - in Eclipse, the Git Staging view's “Staging Area” shows the files ready but not yet committed.

 

Third is the Working Directory. Think of this as the Sandbox in which you can work and actually make changes (the HEAD and Index are not editable files in the same way, they are stored in Git’s internal representation, not directly accessible for editing purposes).

 

The different shades of Reset affect one, two or all three of these sets.

So, in the History view above, everything is updated to version 3 of the Person file. How can we use Eclipse and Git to back up to Person version 2? Right-click on the version 2 commit and choose Reset.

 

Select “Soft (HEAD Only)” to revert to version 2 only in the HEAD file set. This leaves the Index and the Working Directory still on version 3. As a result, the History view changes to reflect the fact that the HEAD now points to Person version 2:

 

And, since the Index and Working Directory still have version 3, the Git Staging view shows that version in the Staged Changes, ready to work on some more in the Working Directory, or commit again.

 

A Mixed Reset affects both the HEAD and the Index versions of the file. Selecting this option alters the History view the same as the Soft Reset above, with the version 3 commit reverted and therefore disappearing. Since the HEAD and Index now have version 2 again, but the Working Directory was not affected by this reset, the file now reappears in the Git Staging view’s “Unstaged Changes” area.

 

A Hard Reset changes the file version in each of the three Git file sets: HEAD, Index and Working Directory. This effectively throws out an entire commit. It disappears from the History, and version 3 is replaced with version 2 in both the Index and the Working Directory as well. Since Eclipse EGit is about to change the Working Directory, it asks, “Are you sure?”

 

Selecting Yes will lose all changes that were made in version 3. They will be gone from the HEAD, the Index and the Working Directory.

 

The Hard Reset is the only time when Reset is dangerous. It is a powerful tool, but use with caution! The other scenarios above can be undone easily enough. But a Hard Reset overwrites the changes (almost) everywhere. If you know your way around the RefLog, you might be able to get it back, but then, why would you be reading this basic introduction to Git Reset?

 

Posted by 셋부터넷
,

blog.devenjoy.com/?p=479

 

Spring boot view template(handlebars), static resource 갱신(without server shutdown) – DevEnjoy

이전까지 spring boot를 사용시에 webapp 폴더를 임의적으로 생성하여 그 하위에 view tempate, static resource를 설정하였다. 하지만 spring boot에서 가이드하는 방식은 resources 하위에 view template과 static resourc

blog.devenjoy.com

 

 

Posted by 셋부터넷
,