4,495,378 th visitor since 2017.2.1 ( Today : 266 )
Programming
No. 632
Name. swindler
Subject. STRICT_TRANS_TABLES , jdbc 에서의 jdbcCompliantTruncation 문제
Main Cate. MySQL
Sub Cate. JSP/Servlet
Date. 2009-05-29 15:56
Hit. 7150 (211.36.27.8)
File.
앞서 설명한 바와 같이
mysql 5.x 에서 생겨난 STRICT_TRANS_TABLES 문제가
jdbc로 연결하는 경우에는 적용되지 않는다.


The driver needs the STRICT_TRANS_TABLES mode enabled to enforce JDBC compliance on
truncation checks.

If you can't use STRICT_TRANS_TABLES as part of your sql_mode, then you'll have to disable
truncation checks by adding "jdbcCompliantTruncation=false" as a URL configuration
parameter.


따라서 아래와 같이 jdbc 연결시에 옵션을 줄수 있다.
아래는 resin database 세팅하는 경우임

아래와 같이 init-param 에서 jdbcCompliantTruncation="false"
옵션을 주면 auto_truncate를 실행하여
data too long 에러를 발생하지 않고 데이터를 insert 한다.


<database>
<jndi-name>insight</jndi-name>
<driver type="org.gjt.mm.mysql.Driver">
<url>jdbc:mysql://localhost:3306/xxx</url>
<user></user>
<password></password>
<init-param jdbcCompliantTruncation="false"/>
</driver>
</database>


[바로가기 링크] : http://coolx.net/cboard/develop/632



andrew 이 설정을 어디서 하면 되나요?
저는 비슷한 에러를 띄고 있는 상태입니다.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException:
### Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect INTEGER value: 'scsc'
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into tb_blog_board(user_id, title, contents, category, blog_contents_img) values (?,?,?,?, ?)
### Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect INTEGER value: 'scsc'
; SQL []; Data truncation: Truncated incorrect INTEGER value: 'scsc'; nested exception is com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect INTEGER value: 'scsc'
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

보시는 것 같이 scsc라는 string을 입력했는데 INTEGER로 인식해버리고 에러가 발생하네요 ㅠ
어떤게 문제일까요?
2019-06-10
Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog