336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

퍼옴글 : https://jun7222.tistory.com/310


스프링 프레임워크 + tomcat 8.0 + oracle 11g 에서 혼자 로컬로 DB를 사용할 때는 아무 문제가

없다가 여러 인원이 DB서버 하나를 사용하게 될 때 발생했던 오류

close()를 해줘야 하는데 안하는게 쌓이다 보니 결국 오류가 뿜음..


ORA-12519, Error preloading the connection pool, no appropriate service handler found 보인다.



경고: Unexpected exception resolving reference

java.sql.SQLException: Error preloading the connection pool

at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2084)

Caused by: java.sql.SQLException: Listener refused the connection with the following error:

ORA-12519, TNS:no appropriate service handler found

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)

org.apache.tomcat.dbcp.dbcp2.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)

... 22 more

Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:

ORA-12519, TNS:no appropriate service handler found

 

at oracle.net.ns.NSProtocol.connect(NSProtocol.java:386)

at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1054)

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:308)

... 31 more

경고: Unexpected exception resolving reference

java.sql.SQLException: Error preloading the connection pool

at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2084)

at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getLogWriter(BasicDataSource.java:1587)

Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:

ORA-12519, TNS:no appropriate service handler found

 

at oracle.net.ns.NSProtocol.connect(NSProtocol.java:386)

at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1054)

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:308)

... 79 more



오류 해결방법

1. close()를 해준다.


2. SELECT * FROM V$SESSION WHERE OSUSER != 'SYSTEM';  으로 점유하는 것을

확인하여 이상이 있는지 체크





이 글에서 소개할 방법은 3번

3. processes의 할당량을 늘려준다.


select * from v$resource_limit where resource_name = 'processes';

위 내용을 입력하여 현재 사용중인 수가 할당보다 많으면 위 오류를 나온다.


현재 32 최대 36 할당 100 




먼저, cmd를 실행한다.

sqlplus /nolog

SQL> conn /as sysdba


SQL>alter system set processes=200 scope=spfile;

               값은 적당하게~


SQL> shutdown immediate;

SQL> startup;




재시작까지 완료되고 다시 확인을 하면




위처럼 allocation, limit 값이 늘어난 걸 확인할 수 있다.



출처: https://jun7222.tistory.com/310 [leverage 블로그]

'DATABASE > ORACLE' 카테고리의 다른 글

ORACLE PROCEDURE 쿼리 COMMIT 또는 ROLLBACK  (0) 2017.02.16
ORACLE FOR LOOP구문  (0) 2017.02.16
ORACLE WHILE문과 LOOP문  (0) 2017.02.16
ORACLE 프로시저 IF문과 EXCEPTION처리방법  (0) 2017.02.16
ORACLE PLSQL  (0) 2017.02.12
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

안녕하세요

이번엔 DB에 있는 값을 EXCEL DOWN에 대해 써보겠습니다.


pom.xml

1
2
3
4
5
<dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.17</version>
        </dependency>
cs


HomeController.java가 있는 패키지에 ExcelController.java를 생성해 주세요.

ExcelController.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@Controller
public class ExcelController {
 
    private static final Logger logger = LoggerFactory.getLogger(ExcelController.class);
    
    //Service 연동
    @Resource(name = "homeService")
    private HomeService homeService;
    
    @RequestMapping(value = "/excelDown.do", method = RequestMethod.POST)
    public void ExcelDown(HttpServletResponse response){
        logger.info("@@@@@@@@@@@@@@@ExcelDown START@@@@@@@@@@@@@@@");
        
        homeService.getExcelDown(response);
        
        logger.info("@@@@@@@@@@@@@@@ExcelDown END@@@@@@@@@@@@@@@");
        
    }
}
cs


HomeService.java

1
public void getExcelDown(HttpServletResponse response);
cs


HomeServiceImpl.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@Override
    public void getExcelDown(HttpServletResponse response) {
        Map<String, Object> map = new HashMap<String, Object>();
        List<?> list = homeMapper.testDbList(map);
        
        try{
            //Excel Down 시작
            Workbook workbook = new HSSFWorkbook();
            //시트생성
            Sheet sheet = workbook.createSheet("게시판");
            
            //행, 열, 열번호
            Row row = null;
            Cell cell = null;
            int rowNo = 0;
            
            // 테이블 헤더용 스타일
            CellStyle headStyle = workbook.createCellStyle();
    
            // 가는 경계선을 가집니다.
            headStyle.setBorderTop(BorderStyle.THIN);
            headStyle.setBorderBottom(BorderStyle.THIN);
            headStyle.setBorderLeft(BorderStyle.THIN);
            headStyle.setBorderRight(BorderStyle.THIN);
    
            // 배경색은 노란색입니다.
            headStyle.setFillForegroundColor(HSSFColorPredefined.YELLOW.getIndex());
            headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    
            // 데이터는 가운데 정렬합니다.
            headStyle.setAlignment(HorizontalAlignment.CENTER);
    
            // 데이터용 경계 스타일 테두리만 지정
            CellStyle bodyStyle = workbook.createCellStyle();
            bodyStyle.setBorderTop(BorderStyle.THIN);
            bodyStyle.setBorderBottom(BorderStyle.THIN);
            bodyStyle.setBorderLeft(BorderStyle.THIN);
            bodyStyle.setBorderRight(BorderStyle.THIN);
    
            // 헤더 생성
            row = sheet.createRow(rowNo++);
    
            cell = row.createCell(0);
            cell.setCellStyle(headStyle);
            cell.setCellValue("번호");
    
            cell = row.createCell(1);
            cell.setCellStyle(headStyle);
            cell.setCellValue("이름");
    
            cell = row.createCell(2);
            cell.setCellStyle(headStyle);
            cell.setCellValue("제목");
    
            // 데이터 부분 생성
            for(Object map1 : list) {
                Map<String, Object> mapValue = (Map<String, Object>) map1;
                
                logger.info("DB DATA : "+mapValue.toString());
                
                row = sheet.createRow(rowNo++);
                cell = row.createCell(0);
                cell.setCellStyle(bodyStyle);
                cell.setCellValue(""+mapValue.get("IDCOL"));
                cell = row.createCell(1);
                cell.setCellStyle(bodyStyle);
                cell.setCellValue(""+mapValue.get("NAMECOL"));
                cell = row.createCell(2);
                cell.setCellStyle(bodyStyle);
                cell.setCellValue(""+mapValue.get("VALUECOL"));
            }
    
            // 컨텐츠 타입과 파일명 지정
            response.setContentType("ms-vnd/excel");
            response.setHeader("Content-Disposition""attachment;filename=test.xls");
 
            // 엑셀 출력
            workbook.write(response.getOutputStream());
            workbook.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        
    }
cs


마지막으로

home.jsp

1
2
3
<form name="excelForm" id="excelForm" method="POST" action="./excelDown.do">
    <input type="submit" id="excelDown" value="EXCEL 다운"/>
</form>
cs

 

후에 실행해보면 ExcelFile을 Down 받아서 보여줍니다.


감사합니다.

'SPRING' 카테고리의 다른 글

SPRING FILE DOWNLOAD하기  (0) 2019.03.28
Spring FileUpload 하기  (0) 2019.03.28
SPRING JSTL 이용해서 Spring 값 뿌리기  (0) 2019.03.27
SPRING resources 사용하기  (0) 2019.03.27
Ambiguous mapping found 에러 해결방법  (0) 2019.03.27
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

안녕하세요.



뿌려줄 데이터입니다.


HomeController.java

결과를 이부분에 저장했습니다.

1
model.addAttribute("dbList", list);
cs


home.jsp

저장한 것을 list라는 변수에 담아 처리했습니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    <!-- 결과값 출력 -->
<table border="1">
    <tr>
        <td>번호</td>
        <td>작성자</td>
        <td>기타</td>
    </tr>
    <c:forEach var="list" items="${dbList }">
        <tr>
            <td>${list.IDCOL }</td>
            <td>${list.NAMECOL }</td>
            <td>${list.VALUECOL }</td>
        </tr>
    </c:forEach>
</table>
cs


감사합니다.

'SPRING' 카테고리의 다른 글

Spring FileUpload 하기  (0) 2019.03.28
Spring Excel down하기  (0) 2019.03.28
SPRING resources 사용하기  (0) 2019.03.27
Ambiguous mapping found 에러 해결방법  (0) 2019.03.27
log4j 로그 패턴들  (0) 2019.03.26

+ Recent posts