dsfsdfsdfsdfsdfgger
170
2018-08-06 11:54:16 작성 2018-08-06 13:06:32 수정됨
7
1412

JSP multipart/form-data 파라미터 값처리.. 질문 드립니다 ㅠㅠ


아무리 해도 안되서 이렇게 질문 올립니다. ㅠㅠ

JSP 고수님 한번만 봐주세요 ㅠㅠㅠㅠ

 enctype="multipart/form-data" 형식으로 파일을 전송할때 

bbs.setBbsTitle(multi.getParameter("bbsTitle")); 이런 씩으로 받아와서 치리 하도록 했는데

글쓰기 하면 자꾸 -1 에러 뜨네요 ㅠ

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

test.jsp 파일 만들어서 여기로 값을 넘겼는데 잘넘어 와요 ㅠㅠ 이거 그러면 BbsDAO.JAVA 파일에 write 부분에 문제 가있는건가요? ㅠㅜ

String aa="";

aa=multi.getParameter("bbsTitle");

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


[ 소스 코드 ]

■ 글쓰기 페이지 (write.jsp)

<form class="row" action="../writeAction.jsp" method="post" enctype="multipart/form-data">

<div class="list-wrap">

            <div class="list-img">

            <!-- 완성도 -->

<div class="slidecontainer html-inupt-range html-input-range-custom">

            <div class="list-content">

                <div class="list-align">

                    <div class="li-title">

                        <div class="title"><input type="text" placeholder="글 제목" name="bbsTitle" maxlength="50" style="width:350px; height:40px; border:0;"></div>

                        <div class="data"></div>

                    </div>

                    <div class="li-content">

                    <select name="fieldName">

<option>테스트 리스트1</option>

<option >테스트 리스트2</option>

<option >테스트 리스트3</option>

 </select>

                    <input type="file" name="fieldNamea">

                    <input type="hidden" name="writeFiledName" value="IMG">

                      <textarea style="width:398px;height:385px; border:0;" placeholder="글 내용" name="bbsContent" maxlength="2048"></textarea>

                      <input type="submit" class="bt btn-primary pull-right" value="글쓰기">

                    </div>

                </div>

            </div>

        </div>

</form>



■ 글쓰기 업로드 (writeAction.jsp)

<%@ page language="java" contentType="text/html; charset=utf-8"

    pageEncoding="UTF-8"%>

<%@ page import="bbs.BbsDAO" %><!-- 방금 만든자바클래스 가져옴( #4강 07:04초)-->

<%@ page import="java.io.PrintWriter" %>

<% request.setCharacterEncoding("UTF-8");%>

<!-- 파일업로드 --> 

<%@page import="java.io.File"%> 

<%@page import="java.util.Enumeration"%> 

<%@page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy"%> 

<%@page import="com.oreilly.servlet.MultipartRequest"%> 

<%

String realFolder = "";

String saveFolder = "upload";

String encType = "utf-8";


ServletContext context = getServletContext();

realFolder = context.getRealPath(saveFolder);

String saveFiles ="";

String origFiles ="";


File f = null;

int maxSize = 1024 * 1024 * 10; // 한번에 올릴 수 있는 파일 용량 : 10M로 제한 

MultipartRequest multi = new MultipartRequest(request,realFolder,maxSize,encType,new DefaultFileRenamePolicy());

bbs.setBbsTitle(multi.getParameter("bbsTitle"));

bbs.setBbsContent(multi.getParameter("bbsContent"));

bbs.setFieldName(multi.getParameter("fieldName"));

bbs.setFieldNamea(multi.getFilesystemName("fieldNamea"));

bbs.setBbsFigure(multi.getParameter("bbsFigure"));

bbs.setWriteFiledName(multi.getParameter("writeFiledName"));

%>

<% 

  // request.getRealPath("상대경로") 를 통해 파일을 저장할 절대 경로를 구해온다. 

  // 운영체제 및 프로젝트가 위치할 환경에 따라 경로가 다르기 때문에 아래처럼 구해오는게 좋음 

  String uploadPath = request.getRealPath("/uploadFile"); 

  out.println("절대경로 : " + uploadPath + "<br/>"); 

        

  String name = ""; 

  String subject = ""; 

    

  String fileName1 = ""; // 중복처리된 이름 

  String originalName1 = ""; // 중복 처리전 실제 원본 이름 

  long fileSize = 0; // 파일 사이즈 

  String fileType = ""; // 파일 타입 

    

    

  try{ 

         // request,파일저장경로,용량,인코딩타입,중복파일명에 대한 기본 정책 

         multi = new MultipartRequest(request,uploadPath,maxSize,"utf-8",new DefaultFileRenamePolicy()); 

           

         // form내의 input name="name" 인 녀석 value를 가져옴 

         name = multi.getParameter("name"); 

         // name="subject" 인 녀석 value를 가져옴 

         subject = multi.getParameter("subject"); 

           

         // 전송한 전체 파일이름들을 가져옴 

         Enumeration files = multi.getFileNames(); 

           

         while(files.hasMoreElements()){ 

                // form 태그에서 <input type="file" name="여기에 지정한 이름" />을 가져온다. 

                String file1 = (String)files.nextElement(); // 파일 input에 지정한 이름을 가져옴 

                // 그에 해당하는 실재 파일 이름을 가져옴 

                originalName1 = multi.getOriginalFileName(file1); 

                // 파일명이 중복될 경우 중복 정책에 의해 뒤에 1,2,3 처럼 붙어 unique하게 파일명을 생성하는데 

                // 이때 생성된 이름을 filesystemName이라 하여 그 이름 정보를 가져온다.(중복에 대한 처리) 

                fileName1 = multi.getFilesystemName(file1); 

                // 파일 타입 정보를 가져옴 

                fileType = multi.getContentType(file1); 

                // input file name에 해당하는 실재 파일을 가져옴 

                File file = multi.getFile(file1); 

                // 그 파일 객체의 크기를 알아냄 

                fileSize = file.length(); 

         } 

     }catch(Exception e){ 

         e.printStackTrace(); 

  } 

%> 


<%@ page import="java.sql.*, java.text.*,java.util.Date,com.oreilly.servlet.MultipartRequest,

     com.oreilly.servlet.multipart.DefaultFileRenamePolicy,java.util.*,java.io.*"%>


<!DOCTYPE html>

<html>

  <head>

    <meta charset="utf-8; contentType=text/html;">

    <title>업로드</title>

</head>

<body>

<!-- 로그인 정보 처리 페이지 -->

<%

//로그인 세션값 읽어와 로그인 여부 확인

String userID =null;

if(session.getAttribute("userID") != null){

userID = (String) session.getAttribute("userID");

}

if(userID == null){

PrintWriter script =response.getWriter();

script.println("<script>");

script.println("alert('로그인 하세요.')");

script.println("location.href = 'login/login.jsp'");

script.println("</script>");

}else{

if(bbs.getBbsTitle() == null || bbs.getBbsContent()==null ){

PrintWriter script =response.getWriter();

script.println("<script>");

script.println("alert('입력이 안된 사항이 있습니다.')");

script.println("history.back()");

script.println("</script>");

} else {

BbsDAO bbsDAO = new BbsDAO();

int result = bbsDAO.write(bbs.getBbsTitle(), userID, bbs.getBbsContent(), bbs.getFieldName(), bbs.getFieldNamea(), bbs.getBbsFigure(), bbs.getWriteFiledName());

if(result == -1){

PrintWriter script =response.getWriter();

script.println("<script>");

script.println("alert('글쓰기에 실패했습니다.')");

script.println("history.back()");

script.println("</script>");

}else{

PrintWriter script =response.getWriter();

script.println("<script>");

script.println("location.href = '../bbs.jsp?userIDS="+userID+"'");

script.println("</script>");

}

}

}

%>

</body>

</html>



■ BbsDAO.java

//게시글 작성

public int write(String bbsTitle, String userID, String bbsContent, String fieldName, String fieldNamea, String bbsFigure, String writeFiledName) {

String SQL = "INSERT INTO BBS VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

try {

PreparedStatement pstmt = conn.prepareStatement(SQL);

pstmt.setInt(1, getNext());

pstmt.setString(2, bbsTitle);

pstmt.setString(3, userID);

pstmt.setString(4, getDate());

pstmt.setString(5, bbsContent);

pstmt.setString(6, fieldName);

pstmt.setString(7, fieldNamea);

pstmt.setString(8, bbsFigure);

pstmt.setString(9, writeFiledName);

pstmt.setInt(10, 1);

return pstmt.executeUpdate();

} catch (Exception e) {

e.printStackTrace();

}return -1;// 데이터 베이스 오류

}


■ DB

 bbsID | bbsTitle | userID | bbsDate | bbsContent | fieldName | fieldNamea | bbsFigure | writeFiledName | bbsAvailable



0
1
  • 답변 7

  • 오후
    1k
    2018-08-06 12:05:15

    -1 말고 error 문을 보여주시는게 더 빠른답변이나올거같네요.

    1
  • dsfsdfsdfsdfsdfgger
    170
    2018-08-06 12:21:35

    콘솔에 있는 내용을 보여드리면 되나요? ㅠ


    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.SetAllPropertiesRule begin

    경고: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'compressableMimeType' to 'text/html,text/xml,text/plain,text/javascript,text/css,application/javascript' did not find a matching property.

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.SetAllPropertiesRule begin

    경고: [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'compressableMimeType' to 'text/html,text/xml,text/plain,text/javascript,text/css,application/javascript' did not find a matching property.

    8월 06, 2018 12:09:10 오후 org.apache.tomcat.util.digester.SetPropertiesRule begin

    경고: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:BBS' did not find a matching property.

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: Server version:        Apache Tomcat/9.0.10

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: Server built:          Jun 20 2018 17:32:21 UTC

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: Server number:         9.0.10.0

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: OS Name:               Windows 10

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: OS Version:            10.0

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: Architecture:          amd64

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: Java Home:             C:\Program Files\Java\jre1.8.0_171

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: JVM Version:           1.8.0_171-b11

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: JVM Vendor:            Oracle Corporation

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: CATALINA_BASE:         C:\JSP\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: CATALINA_HOME:         C:\JSP\Tomcat 9.0

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: Command line argument: -Dcatalina.base=C:\JSP\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: Command line argument: -Dcatalina.home=C:\JSP\Tomcat 9.0

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: Command line argument: -Dwtp.deploy=C:\JSP\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: Command line argument: -Djava.endorsed.dirs=C:\JSP\Tomcat 9.0\endorsed

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.VersionLoggerListener log

    정보: Command line argument: -Dfile.encoding=MS949

    8월 06, 2018 12:09:10 오후 org.apache.catalina.core.AprLifecycleListener lifecycleEvent

    정보: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_171\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_171/bin/server;C:/Program Files/Java/jre1.8.0_171/bin;C:/Program Files/Java/jre1.8.0_171/lib/amd64;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Java\jdk-10.0.1\bin;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files (x86)\Brackets\command;C:\Users\김태경\AppData\Local\Microsoft\WindowsApps;C:\Users\김태경\AppData\Local\atom\bin;C:\util\openssl-0.9.8k_X64\bin;C:\Program Files\Bandizip\;C:\Windows\System32;;.]

    8월 06, 2018 12:09:10 오후 org.apache.coyote.http11.AbstractHttp11Protocol configureUpgradeProtocol

    정보: The ["http-nio-80"] connector has been configured to support HTTP upgrade to [h2c]

    8월 06, 2018 12:09:10 오후 org.apache.coyote.AbstractProtocol init

    정보: Initializing ProtocolHandler ["http-nio-80"]

    8월 06, 2018 12:09:10 오후 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

    정보: Using a shared selector for servlet write/read

    8월 06, 2018 12:09:10 오후 org.apache.coyote.http11.AbstractHttp11Protocol configureUpgradeProtocol

    심각: The upgrade handler [org.apache.coyote.http2.Http2Protocol] for [h2] only supports upgrade via ALPN but has been configured for the ["https-jsse-nio-443"] connector that does not support ALPN.

    8월 06, 2018 12:09:10 오후 org.apache.coyote.AbstractProtocol init

    정보: Initializing ProtocolHandler ["https-jsse-nio-443"]

    8월 06, 2018 12:09:10 오후 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

    정보: Using a shared selector for servlet write/read

    8월 06, 2018 12:09:10 오후 org.apache.coyote.AbstractProtocol init

    정보: Initializing ProtocolHandler ["ajp-nio-8009"]

    8월 06, 2018 12:09:10 오후 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector

    정보: Using a shared selector for servlet write/read

    8월 06, 2018 12:09:10 오후 org.apache.catalina.startup.Catalina load

    정보: Initialization processed in 640 ms

    8월 06, 2018 12:09:10 오후 org.apache.catalina.core.StandardService startInternal

    정보: Starting service [Catalina]

    8월 06, 2018 12:09:10 오후 org.apache.catalina.core.StandardEngine startInternal

    정보: Starting Servlet Engine: Apache Tomcat/9.0.10

    8월 06, 2018 12:09:14 오후 org.apache.jasper.servlet.TldScanner scanJars

    정보: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

    8월 06, 2018 12:09:14 오후 org.apache.coyote.AbstractProtocol start

    정보: Starting ProtocolHandler ["http-nio-80"]

    8월 06, 2018 12:09:14 오후 org.apache.coyote.AbstractProtocol start

    정보: Starting ProtocolHandler ["https-jsse-nio-443"]

    8월 06, 2018 12:09:14 오후 org.apache.coyote.AbstractProtocol start

    정보: Starting ProtocolHandler ["ajp-nio-8009"]

    8월 06, 2018 12:09:14 오후 org.apache.catalina.startup.Catalina start

    정보: Server startup in 3661 ms

    java.io.IOException: Corrupt form data: premature ending

    at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:207)

    at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:223)

    at org.apache.jsp.post.writeAction_jsp._jspService(writeAction_jsp.java:217)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at core.init.HSTSFilter.doFilter(HSTSFilter.java:22)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:608)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)

    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)

    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Unknown Source)

    com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '2' for key 'PRIMARY'

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

    at java.lang.reflect.Constructor.newInstance(Unknown Source)

    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)

    at com.mysql.jdbc.Util.getInstance(Util.java:408)

    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)

    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)

    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)

    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)

    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)

    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)

    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013)

    at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104)

    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998)

    at bbs.BbsDAO.write(BbsDAO.java:101)

    at org.apache.jsp.post.writeAction_jsp._jspService(writeAction_jsp.java:279)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at core.init.HSTSFilter.doFilter(HSTSFilter.java:22)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:608)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)

    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)

    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Unknown Source)

    java.io.IOException: Corrupt form data: premature ending

    at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:207)

    at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:223)

    at org.apache.jsp.post.writeAction_jsp._jspService(writeAction_jsp.java:217)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at core.init.HSTSFilter.doFilter(HSTSFilter.java:22)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:608)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)

    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)

    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Unknown Source)

    com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '2' for key 'PRIMARY'

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

    at java.lang.reflect.Constructor.newInstance(Unknown Source)

    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)

    at com.mysql.jdbc.Util.getInstance(Util.java:408)

    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)

    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)

    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)

    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)

    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)

    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)

    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013)

    at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104)

    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998)

    at bbs.BbsDAO.write(BbsDAO.java:101)

    at org.apache.jsp.post.writeAction_jsp._jspService(writeAction_jsp.java:279)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at core.init.HSTSFilter.doFilter(HSTSFilter.java:22)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:608)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)

    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)

    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Unknown Source)

    java.io.IOException: Corrupt form data: premature ending

    at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:207)

    at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:223)

    at org.apache.jsp.post.writeAction_jsp._jspService(writeAction_jsp.java:217)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at core.init.HSTSFilter.doFilter(HSTSFilter.java:22)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:608)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)

    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)

    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Unknown Source)

    com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '2' for key 'PRIMARY'

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

    at java.lang.reflect.Constructor.newInstance(Unknown Source)

    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)

    at com.mysql.jdbc.Util.getInstance(Util.java:408)

    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)

    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)

    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)

    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)

    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)

    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)

    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013)

    at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104)

    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998)

    at bbs.BbsDAO.write(BbsDAO.java:101)

    at org.apache.jsp.post.writeAction_jsp._jspService(writeAction_jsp.java:279)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at core.init.HSTSFilter.doFilter(HSTSFilter.java:22)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:608)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)

    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)

    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Unknown Source)

    Mon Aug 06 12:15:31 KST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

    Mon Aug 06 12:15:31 KST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

    Mon Aug 06 12:15:33 KST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

    Mon Aug 06 12:15:33 KST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

    java.io.IOException: Corrupt form data: premature ending

    at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:207)

    at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:223)

    at org.apache.jsp.post.writeAction_jsp._jspService(writeAction_jsp.java:217)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at core.init.HSTSFilter.doFilter(HSTSFilter.java:22)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:608)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)

    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)

    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Unknown Source)

    com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '2' for key 'PRIMARY'

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

    at java.lang.reflect.Constructor.newInstance(Unknown Source)

    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)

    at com.mysql.jdbc.Util.getInstance(Util.java:408)

    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)

    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)

    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)

    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)

    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)

    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)

    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013)

    at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104)

    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998)

    at bbs.BbsDAO.write(BbsDAO.java:101)

    at org.apache.jsp.post.writeAction_jsp._jspService(writeAction_jsp.java:279)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at core.init.HSTSFilter.doFilter(HSTSFilter.java:22)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:608)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)

    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)

    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Unknown Source)

    java.io.IOException: Corrupt form data: premature ending

    at com.oreilly.servlet.multipart.MultipartParser.<init>(MultipartParser.java:207)

    at com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:223)

    at org.apache.jsp.post.writeAction_jsp._jspService(writeAction_jsp.java:217)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at core.init.HSTSFilter.doFilter(HSTSFilter.java:22)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:608)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)

    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)

    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Unknown Source)

    com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '2' for key 'PRIMARY'

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

    at java.lang.reflect.Constructor.newInstance(Unknown Source)

    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)

    at com.mysql.jdbc.Util.getInstance(Util.java:408)

    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)

    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)

    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)

    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)

    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)

    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)

    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013)

    at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104)

    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998)

    at bbs.BbsDAO.write(BbsDAO.java:101)

    at org.apache.jsp.post.writeAction_jsp._jspService(writeAction_jsp.java:279)

    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:444)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at core.init.HSTSFilter.doFilter(HSTSFilter.java:22)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)

    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:608)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)

    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)

    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)

    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:764)

    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1388)

    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

    at java.lang.Thread.run(Unknown Source)


    0
  • 하늘보는나
    111
    2018-08-06 13:27:52

    com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '2' for key 'PRIMARY'


    pk 값 중복인 것 같은데요....

    0
  • dsfsdfsdfsdfsdfgger
    170
    2018-08-06 13:50:01 작성 2018-08-06 14:06:37 수정됨

    어느 부분을 건드려야 할지 모르겠어요 ㅠㅠ

    해당 테이블 검색 해보니깐 PK 중복 된 부분은 없어여 ㅠ


    | bbs   | CREATE TABLE `bbs` (

      `bbsID` int(11) NOT NULL,

      `bbsTitle` varchar(50) DEFAULT NULL,

      `userID` varchar(20) DEFAULT NULL,

      `bbsDate` datetime DEFAULT NULL,

      `bbsContent` varchar(2048) DEFAULT NULL,

      `fieldName` varchar(50) DEFAULT NULL,

      `fieldNamea` varchar(75) DEFAULT NULL,

      `bbsFigure` varchar(30) DEFAULT '0',

      `writeFiledName` varchar(10) DEFAULT '0',

      `bbsAvailable` varchar(75) DEFAULT NULL,

      PRIMARY KEY (`bbsID`)

    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |

    0
  • 오후
    1k
    2018-08-06 14:14:17

    pstmt.setInt(1, getNext());

    이게 아마 bbsID 조회해온후 할당하시는거같은데 
    PK 값이 2인데 INSERT 를 2로 해서 중복이라는거같아요.

    getNext()  <--  쿼리확인해보세요 어떤식으로가져오시는지

    1
  • 하늘보는나
    111
    2018-08-06 14:16:01

    bbsID 에 동일한 값이 두번 들어가는 것 같은데요...

    혹시 pstmt 를 로그로 찍으면 어떻게 나오나요??

    1
  • dsfsdfsdfsdfsdfgger
    170
    2018-08-06 14:49:50 작성 2018-08-06 15:01:41 수정됨

    혹시나 싶어서 DB데이터 내용다 삭제 하니깐 해결은 되는거에요 ㅠㅠ 그래서 글쓰기 하고 삭제하고 다시 글쓰기 하면 안되더라고요 ㅠ원인을 알아보니 bbsAvailable = 1  이 아이가 문제였으여 ㅠㅠ

    다들 감사합니다. ㅠㅠ

    getNext() 쿼리보면 이렇게 

    public int getNext() {

    String SQL = "SELECT bbsID FROM BBS WHERE bbsAvailable = 1 ORDER BY bbsID DESC";

    try {

    PreparedStatement pstmt = conn.prepareStatement(SQL);

    rs = pstmt.executeQuery();

    if(rs.next()) {

    return rs.getInt(1) + 1;

    }

    return 1; //첫번째 게시물인 경우

    } catch (Exception e) {

    e.printStackTrace();

    }return -1;// 데이터 베이스 오류

    }

    0
  • 로그인을 하시면 답변을 등록할 수 있습니다.