Ucho
110
2019-07-16 20:47:25
6
169

java 게시판 중에서 게시물 수정에서 sql 부적합하다고 나오네요...


Update.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var = "dto" value = "${result}"/>
.. 생략
<section>
	<article>
		<h2>게시판 본문</h2>
		<form name = "content" >
			<table border = "3" width = "550" cellspacing = "0">
				<tr>
					<th>번호</th>
					<td><input type = "hidden" name = "tindex" value = "${dto.tindex}"></td>
					<th>작성날짜</th>
					<td><input type = "text" name = "tpostdate" value = "${dto.tpostdate}"></td>
				</tr>
				<tr>
					<th>작성자</th>
					<td><input type = "text" name = "tnickname" value = "${dto.tnickname}" readonly = "readonly"></td>
					<th>조회수</th>
					<td><input type = "text" name = "tviewcount" value = "${dto.tviewcount}"></td>
					<td>카테고리</td>
						<td>
							<select name = "tcategory">
								<option>선택</option>
								<option>1</option>
								<option>2</option>
								<option>3</option>
								<option>4</option>
							</select>
						</td>
				</tr>
				<tr>
					<th>제목</th>
					<td colspan = "4" value = "${dto.ttitle}"></td>
				</tr>
				<tr>
					<td colspan = "4"><textarea rows="10" cols="65" name ="tcontent" value = "${dto.tcontent}"></textarea></td>
				</tr>
				<tr>
					<td colspan = "4" align = "center">
					<a href = "bbsUpdate_ok.BT"><input type = "button" value = "수정완료"></a>
					<a href = "bbsList.BT"><input type = "button" value = "목록으로"></a>
					</td>
				</tr>
			</table>
		</form>
	</article>
</section>


sqlMap.xml (Update)

tpostdate = sysdate -> 수정한날짜를 구하기 위해서 했습니다

<update id="bbsUpdate" parameterType="bbs.model.BbsDTO">
  		update BT_TEXT set
  		ttitle = #{ttitle},
  		tcontent = #{tcontent},
  		tpostdate = sysdate,
  		tcategoty = #{tcategoty}
  	</update>

sqlMap.xml (insert) => 참고용

<insert id="bbsInsert" parameterType="bbs.model.BbsDTO">
  		insert into
  			BT_TEXT
  				values(BT_TEXT_tindex.nextval,
  			#{tnickname},#{ttitle},#{tcontent},sysdate,#{tcategory},0,0,0,0,0,0)
  	</insert>

에러 내용

Servlet.service() for servlet [dispatcher] in context with path [/BT-Plan] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property='ttitle', 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 #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: 부적합한 열 유형: 1111] with root cause
java.sql.SQLException: 부적합한 열 유형: 1111
	at oracle.jdbc.driver.OracleStatement.getInternalType(OracleStatement.java:3900)
	at oracle.jdbc.driver.OraclePreparedStatement.setNullCritical(OraclePreparedStatement.java:4406)
	at oracle.jdbc.driver.OraclePreparedStatement.setNull(OraclePreparedStatement.java:4388)
	at oracle.jdbc.driver.OraclePreparedStatementWrapper.setNull(OraclePreparedStatementWrapper.java:1281)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:108)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:108)
	at org.apache.ibatis.type.BaseTypeHandler.setParameter(BaseTypeHandler.java:45)
	at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:87)
	at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:93)
	at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:64)
	at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:86)
	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:49)
	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
	at com.sun.proxy.$Proxy7.update(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:294)
	at bbs.model.BbsDAOImple.bbsUpdate(BbsDAOImple.java:51)
	at controller.BbsController.bbsUpdatesend(BbsController.java:85)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:180)
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440)
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
	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:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	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:493)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)
	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:798)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

에러 내용으로 볼때는 sqlMap(Update)쪽에 sql 문법 문제인거 까지는 파악이 됬는데

어느 부분에서 틀렷는지 감이안잡혀요 ... 선생님들 따뜻한 조언한마디 부탁드릴게요


0
0
  • 답변 6

  • Spring_Boot개발자
    303
    2019-07-16 20:55:19

    부적한열이 나왔다는건 아무래도 현재 수정 페이지에서 문제가 있는 것으로 나오거든요

    ${} view 호출은 했지만 form 태그 안에 컬럼이름들이 인식을 안한 것 같습니다. 확인 해보시겠어요?


    1
  • Ucho
    110
    2019-07-16 21:02:59

    지금 이클립스를 꺼서 ㅠㅠ

    일단은 집에가서 form태그 안에 있는 컬럼들을 button이 아닌 submit 으로 값을 넘겨주도록 해볼게요 

    말씀들어보니 submit으로 넘기는게 맞을수도 있다는 생각이드네여

    0
  • 띠옹바루
    177
    2019-07-16 22:06:14 작성 2019-07-16 22:09:51 수정됨

    제목에 name 빠진거 아닌가요?

    ttitle 이거 input에 넣어야 할것 같은데요?

    1
  • Ucho
    110
    2019-07-17 09:31:36

    두분 말씀대로 확인해보고 

    제목 부분에 name="ttitle" 추가해서 

    input 에 값넣어서 진행행봐도 부적합한 열유형이라고 작성이 되네여 ..

    0
  • 멜로님
    8
    2019-07-17 10:25:19
     ParameterMapping{property='ttitle', 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 #1 with JdbcType OTHER .

    현재로선 ttitle이 null값으로 들어오는게 맞는것같아요.

    ttitle의 name을 td에 주셨을것같은데, 그러면 form태그가 읽지 못하게되죠~

    1. <input type="hidden" name="ttitle" value="${dto.ttitle"}> 를 폼안에 선언해서 ttitle넘기기

    2. 서비스로직에서 현재 pk값 (index겠죠?) 으로 조회해서 ttitle을 조회해서 dto에 넣기

    2가지정도 방법으로 해결하실수있을것같아요~

    0
  • Ucho
    110
    2019-07-17 12:33:14

    멜로님 답변 감사합니다

    확인해보니 일단 parameter 넘기는 부분에서 button 이 아닌 submit으로 접근을 해서 파라미터 넘기는 부분을 해결하고

    그 이후에 계속 매핑 문제가 발생을 해서 bbs_Update.jsp 에서 작성날짜 부분에 name 을 Uppostdate으로 수정하고 controller 부분에서 @RequestParam("Uppostdate")String tpostdate 을 매개변수로 추가 해줬더니 다 해결됬습니다.

    근본적인 문제는 button -> submit 차이였고 위에서 말씀해주신 ttitle도 수정하였습니다

    그리고 수정날짜도 갱신하고싶었는데 그문제는 @RequestParam("Uppostdate")String tpostdate을 추가함으로써 해결되었습니다.

    검색해서 다른분들이 보실걸 생각해서 수정본 올려드립니다

    도와주신 모든분들께 다시한번 감사말씀올립니다

    Controller
    @RequestMapping("/bbsUpdate_ok.BT")
    	public ModelAndView bbsUpdatesend(BbsDTO dto,@RequestParam("Uppostdate")String tpostdate)
    	{
    		int result = bbsDao.bbsUpdate(dto);
    		String msg =result>0?"수정 성공":"수정 실패";
    		ModelAndView mav = new ModelAndView();
    		mav.addObject("upmsg",msg);
    		mav.setViewName("bbs/ok/bbs_Update_ok");
    		return mav;
    	}
    
    bbs_Update.jsp
    <section>
    	<article>
    		<h2>게시판 본문</h2>
    		<form name = "content" action = "bbsUpdate_ok.BT">
    			<table border = "3" width = "550" cellspacing = "0">
    				<tr>
    					<th>번호</th>
    					<td><input type = "text" name = "tindex" value = "${dto.tindex}"></td>
    					<th>작성날짜</th>
    					<td><input type = "text" name = "Uppostdate" value = "${dto.tpostdate}"></td>
    				</tr>
    				<tr>
    					<th>작성자</th>
    					<td><input type = "text" name = "tnickname" value = "${dto.tnickname}" readonly = "readonly"></td>
    					<th>조회수</th>
    					<td><input type = "text" name = "tviewcount" value = "${dto.tviewcount}" readonly = "readonly"></td>
    					<td>카테고리</td>
    						<td>
    							<select name = "tcategory">
    								<option value = "1" selected>${dto.tcategory}</option>
    								<option value = "2">1</option>
    								<option value = "3">2</option>
    								<option value = "4">3</option>
    								<option value = "5">4</option>
    							</select>
    						</td>
    						
    				</tr>
    				<tr> 
    					<th>제목</th>
    					<td colspan = "4"><input type = "text" name = "ttitle" value = "${dto.ttitle}"></td>
    				</tr>
    				<tr>
    					<td colspan = "4"><textarea rows="10" cols="65" name ="tcontent" >${dto.tcontent}</textarea></td>
    				</tr>
    				<tr>
    					<td colspan = "4" align = "center">
    					<input type = "submit" value = "수정완료">
    					<a href = "bbsList.BT">목록보기</a>
    					</td>
    				</tr>
    			</table>
    		</form>
    	</article>
    </section>
    
    bbsSql.xml
    <update id="bbsUpdate" parameterType="bbs.model.BbsDTO">
      		update BT_TEXT
      		set 
      		tviewcount = #{tviewcount},
      		tnickname = #{tnickname},
      		ttitle = #{ttitle},
      		tcontent = #{tcontent},
      		tpostdate = sysdate,
      		tcategory = #{tcategory}
      		where tindex = #{tindex}	
      	</update>
    
    bbsDAO.java
    public int bbsViewCount(int tindex) 
    	{
    		int count = sqlMap.update("bbsViewCount",tindex);
    		return count;
    	}
    


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