yhhhhhhhj
64
2019-07-11 11:51:19
3
245

초보가 게시판 글쓰기 질문드립니다ㅜㅜㅜ


어느 부분 오류인가요...ㅜㅜ

//controller

//list -> 리뷰 작성

@RequestMapping(value = "/review_insert", method = RequestMethod.GET)

public String review_insert(Model model) {

return "/review_insert";

}

//자료들을 넘겨주는 맵핑

   //insert_book

   @RequestMapping(value = "/insert_book", method = RequestMethod.GET)

   public String insert_book(Model model) {

//제가 적은 글을 넘겨주는 매핑... 어떻게 짜야할까요ㅜ


   return "/review_insert";

   }

//리뷰 등록 파일 업로드

@RequestMapping(value = "/insert_review", method = RequestMethod.POST)

   public String insert_review(ReviewDto rDto, 

   @RequestParam("uploadimg") MultipartFile imgFile,

   Model model,RedirectAttributes rttr) {

   

   UUID uuid = UUID.randomUUID();

   

       String originalFilename = imgFile.getOriginalFilename(); // fileName.jpg

       String onlyFileName = originalFilename.substring(0, originalFilename.indexOf(".")); // fileName

       String extension = originalFilename.substring(originalFilename.indexOf(".")); // .jpg

       String fullpath = saveDir + uuid + "_" + onlyFileName + extension;

           String imgName = uuid + "_" + originalFilename;

           rDto.setREVIEW_IMAGE(imgName);

       if(!imgFile.isEmpty()) {

          try { 

             byte[] bytes = imgFile.getBytes(); 

             BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(fullpath)));

             stream.write(bytes);

             stream.close();

         }catch(Exception e) {

            e.printStackTrace(); 

         } 

       }else {

       }

   

       hotelservice.insert_review(rDto);

   

   return "redirect:/review_list";

   }

}


//jsp


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

    pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<%@include file="includes/header.jsp"%>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Reviews</title>

 


<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">

<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!------ Include the above in your HEAD tag ---------->

</head> 

<body style="background-color:#BDBDBD;">


<form action="insert_review" method="post" enctype="multipart/form-data">

<div style="width: 80%; margin: 30px auto; background-color: #FAFAFA"> 

<br>

    <!-- 이미지 첨부  -->

<div class="form-group" style="width: 80%; margin: 30px auto; ">

<div style="width: 300px; height: 300px;">

<div style="display: inline-block; border: 1px solid #BDBDBD; border-radius: 2px; margin: 1px 1px; background-color: white;">

<div style="font-family: inherit; font-weight: bold; text-align: center;">-이미지 첨부-</div>

<div><img src="resources/images/review.png" class="card-img" alt="..." width="250px;"></div> 

<div style="padding: 3px 10px; margin: 0 auto;">

<input type="file" class="btn btn-outline-dark btn-sm" name="uploadimg">

</div> 

</div>

</div>

</div> 

<br>

<br>

  <!--  리뷰 내용  --> 

<div style="width: 80%; margin: 30px auto;">

    <div class="row form-group">

        <div class="col-md-12 mb-3 mb-md-0">

          <label class="font-weight-bold">TITLE</label>

          <input type="text" name="REVIEW_TITLE" class="form-control" placeholder="제목을 입력하세요">

        </div>

     </div>

    

<div>

<textarea cols="35" rows="7" class="form-control"  name="REVIEW_CONTENT" placeholder="후기를 입력하세요"></textarea>

</div>

</div>

<!-- 리뷰 등록 버튼 -->

<div style="width: 80%; margin: 30px auto;">

<input type="submit" value="리뷰등록" class="btn btn-outline-dark btn-lg">

</div>

<br>

</div>

</form>

<br>

<br>

<br>


<script>

    var upload = document.getElementsByTagName('input')[0],

        holder = document.getElementById('holder'),

        state = document.getElementById('status');

    

    if (typeof window.FileReader === 'undefined') {

      state.className = 'fail';

    } else {}

     

    upload.onchange = function (e) {

      e.preventDefault();

    

      var file = upload.files[0],

          reader = new FileReader();

      reader.onload = function (event) {

        var img = new Image();

        img.src = event.target.result;

        // note: no onload required since we've got the dataurl...I think! :)

        if (img.width > 300 || img.height > 300) { // holder width

          img.width = 300;

        img.height = 300;

        }

        holder.innerHTML = '';

        holder.appendChild(img);

      };

      reader.readAsDataURL(file);

    

      return false;

    };

</script>

<%@include file="includes/footer.jsp"%> 


//mapper

<insert id="insert_review" parameterType="review">

INSERT INTO REVIEW(

REVIEW_NUM,

REVIEW_TITLE,

REVIEW_CONTENT,

REVIEW_IMAGE,

REVIEW_INDATE,

REVIEW_ID

)

  VALUES(

SEQ_REWIEW_NUM.nextval,

#{REVIEW_TITLE},

#{REVIEW_CONTENT},

#{REVIEW_IMAGE},

SYSDATE,

#{REVIEW_ID}

)

</insert>





//오류

근본 원인 (root cause)

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='REVIEW_ID', mode=IN, javaType=class java.lang.String, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}. Cause: org.apache.ibatis.type.TypeException: Error setting null for parameter #4 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 부적합한 열 유형: 1111
	org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
	org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
	com.sun.proxy.$Proxy49.insert(Unknown Source)
	org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
	com.hotel.myhotel.dao.hotelDaoImpl.insert_review(hotelDaoImpl.java:43)
	com.hotel.myhotel.service.hotelServiceImpl.insert_review(hotelServiceImpl.java:61)
	com.hotel.myhotel.controller.HotelController.insert_review(HotelController.java:154)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	java.lang.reflect.Method.invoke(Unknown Source)
	org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
	org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
	org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783)
	org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

근본 원인 (root cause)

근본 원인 (root cause)

java.sql.SQLException: 부적합한 열 유형: 1111
	oracle.jdbc.driver.OracleStatement.getInternalType(OracleStatement.java:4031)
	oracle.jdbc.driver.OraclePreparedStatement.setNullCritical(OraclePreparedStatement.java:4182)
	oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:4166)
	oracle.jdbc.driver.OraclePreparedStatementWrapper.setNull(OraclePreparedStatementWrapper.java:1008)
	com.zaxxer.hikari.pool.HikariProxyPreparedStatement.setNull(HikariProxyPreparedStatement.java)
	org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:61)
	org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:87)
	org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:94)
	org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:64)
	org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:87)
	org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:49)
	org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
	org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
	org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
	org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	java.lang.reflect.Method.invoke(Unknown Source)
	org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
	com.sun.proxy.$Proxy49.insert(Unknown Source)
	org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
	com.hotel.myhotel.dao.hotelDaoImpl.insert_review(hotelDaoImpl.java:43)
	com.hotel.myhotel.service.hotelServiceImpl.insert_review(hotelServiceImpl.java:61)
	com.hotel.myhotel.controller.HotelController.insert_review(HotelController.java:154)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	java.lang.reflect.Method.invoke(Unknown Source)
	org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
	org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
	org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783)
	org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974)
	org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:877)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

비고 근본 원인(root cause)의 풀 스택 트레이스를, 서버 로그들에서 확인할 수 있습니다.



리뷰 등록을 클릭하는 순간 오류가 뜨네요..

0
0
  • 답변 3

  • Balmy
    747
    2019-07-11 12:00:43

    하나하나 차근차근 에러를 찾아보세요


    등록클릭시 가게 해두신 곳에 콘솔로그를 찍어서 그쪽으로 오긴 하는지 보시고

    온다면 어느부분에서 오류가 나는지 확인을 위해 한개 실행 후 로그찍고 이런식으로 찾아보세요


    지금 너무 중구난방으로 쓰여있어서 찾아드리기가 힘들어요

    0
  • ksshim86
    1k
    2019-07-11 12:10:25
    java.sql.SQLException: 부적합한 열 유형: 1111


    기억이 가물가물한데요. REVIEW_ID 파라미터로 넘어오는 타입과 실제 DB 타입과 맞지않아서 나는 에러일껍니다. 아마도??


    0
  • olivvve
    946
    2019-07-11 12:47:12

    컨트롤러에서는 서비스에 dto를 파라미터로 넘기고있는데, 쿼리에서는 review로 받고있는데 review라는게 뭔지 여기서는 잘 모르겠네요. dto하고 서비스단도 올려주세요

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