我正在尝试使用更新语句更新我的数据库,当我尝试这样做时它会向我显示错误...这些是我可以在这里找到的例外。
com.mysql.jdbc.MysqlDataTruncation:数据截断:第1行的列'name'的数据太长 在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2973) 在com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600) 在com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1695) 在com.mysql.jdbc.Connection.execSQL(Connection.java:3020) 在com.mysql.jdbc.Statement.executeUpdate(Statement.java:1074) 在com.mysql.jdbc.Statement.executeUpdate(Statement.java:1008) at data.changing.jButton1ActionPerformed(changing.java:125) at data.changing.access $ 000(changing.java:21) at data.changing $ 1.actionPerformed(changing.java:62) 在javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) 在javax.swing.AbstractButton $ Handler.actionPerformed(AbstractButton.java:2341) 在javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) 在javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) 在javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) 在java.awt.Component.processMouseEvent(Component.java:6505) 在javax.swing.JComponent.processMouseEvent(JComponent.java:3320) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) at java.awt.Container.dispatchEventImpl(Container.java:2273) at java.awt.Window.dispatchEventImpl(Window.java:2719) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735) at java.awt.EventQueue.access $ 200(EventQueue.java:103) at java.awt.EventQueue $ 3.run(EventQueue.java:694) at java.awt.EventQueue $ 3.run(EventQueue.java:692) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue $ 4.run(EventQueue.java:708) at java.awt.EventQueue $ 4.run(EventQueue.java:706) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:705) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138) at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
答案 0 :(得分:4)
你可以解决这个错误,在Jboss数据源中添加属性就像 JDBC:MySQL的://本地主机:1189 / DBNAME jdbcCompliantTruncation =假安培; zeroDateTimeBehavior = convertToNull&安培;的characterEncoding = UTF-8
您可以添加jdbc truncation false来解决此错误。但您的数据将根据值被截断。
答案 1 :(得分:1)
这是因为该coloumn的大小小于您尝试插入的数据,因此将该coloumn的数据类型更改为更大的数据类型(例如,代替char使用varchar ..)那么就没有问题< / p>
答案 2 :(得分:0)
您遇到此异常可能是因为您尝试使用比create语句中定义的SQL列长度更长的字符串更新列。如果您在数据库中设置了正确的字符编码,请确保使用较短或相等的字符串(而不是列定义)保存操作,如果您有特殊标记,可能会以此类异常结束。