问答详情
源自:6-2 综合练习---实现分析

上传图片失败 这个报错是图片太大?看不太懂...求大佬

服务器启动,等待客户端连接

com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'fcontent' at row 1

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

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

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

at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)

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

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

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

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

at com.socket.service.FileService.save(FileService.java:26)

at com.socket.socket.ServerThread.execute(ServerThread.java:66)

at com.socket.socket.ServerThread.run(ServerThread.java:31)

com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'fcontent' at row 1

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

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

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

at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)

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

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

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

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

at com.socket.service.FileService.save(FileService.java:26)

at com.socket.socket.ServerThread.execute(ServerThread.java:67)

at com.socket.socket.ServerThread.run(ServerThread.java:31)


提问者:街边七号 2017-12-16 17:46

个回答

  • 慕粉1470873974
    2018-10-09 00:03:03

    在MySQL中有四种Blob类型,他们的区别就是可以容纳的信息量不容分别是以下四种:
    1.TinyBlob类型  最大能容纳255B的数据
    2.Blob类型  最大能容纳65KB的
    3.MediumBlob类型  最大能容纳16MB的数据
    4.LongBlob类型  最大能容纳4GB的数据

    很有可能是图片太大了,Blob容纳不了,可以换成MediumBlob类型,亲测有效。


  • qq_匠_0
    2017-12-26 12:05:54

    去数据库把fcontent字段长度改长一点试试