CMS(新闻发布系统)存放新闻表内容的字段是text,数据过多无法插入,解决办法!

来源:互联网 发布:linux连不通数据库端口 编辑:程序博客网 时间:2024/04/30 16:28

  在做CMS的时候,插入新闻内容的时候,因为插入的数据过多,报错!出现无法插入的错误,第一时间想到text类型数据大小的限制,就上网搜索,换一下字段类型就可以了。做该项目的时候,用了百度编辑器!

Java和MySQL数据类型对应一览

Table 20.25. MySQL Types to Java Types for ResultSet.getObject()MySQL Type NameReturn value ofGetColumnClassNameReturned as Java ClassBIT(1) (new in MySQL-5.0)BITjava.lang.BooleanBIT( > 1) (new in MySQL-5.0)BITbyte[]TINYINTTINYINTjava.lang.Boolean if the configuration property tinyInt1isBit is set to true (the default) and the storage size is 1, orjava.lang.Integer if not.BOOL, BOOLEANTINYINTSee TINYINT, above as these are aliases forTINYINT(1), currently.SMALLINT[(M)] [UNSIGNED]SMALLINT [UNSIGNED]java.lang.Integer (regardless ifUNSIGNED or not)MEDIUMINT[(M)] [UNSIGNED]MEDIUMINT [UNSIGNED]java.lang.Integer, if UNSIGNEDjava.lang.Long (C/J 3.1 and earlier), orjava.lang.Integer for C/J 5.0 and laterINT,INTEGER[(M)] [UNSIGNED]INTEGER [UNSIGNED]java.lang.Integer, if UNSIGNEDjava.lang.LongBIGINT[(M)] [UNSIGNED]BIGINT [UNSIGNED]java.lang.Long, if UNSIGNEDjava.math.BigIntegerFLOAT[(M,D)]FLOATjava.lang.FloatDOUBLE[(M,B)]DOUBLEjava.lang.DoubleDECIMAL[(M[,D])]DECIMALjava.math.BigDecimalDATEDATEjava.sql.DateDATETIMEDATETIMEjava.sql.TimestampTIMESTAMP[(M)]TIMESTAMPjava.sql.TimestampTIMETIMEjava.sql.TimeYEAR[(2|4)]YEARIf yearIsDateType configuration property is set to false, then the returned object type isjava.sql.Short. If set to true (the default), then the returned object is of typejava.sql.Date with the date set to January 1st, at midnight.CHAR(M)CHARjava.lang.String (unless the character set for the column is BINARY, then byte[] is returned.VARCHAR(M) [BINARY]VARCHARjava.lang.String (unless the character set for the column is BINARY, then byte[] is returned.BINARY(M)BINARYbyte[]VARBINARY(M)VARBINARYbyte[]TINYBLOBTINYBLOBbyte[]TINYTEXTVARCHARjava.lang.StringBLOBBLOBbyte[]TEXTVARCHARjava.lang.StringMEDIUMBLOBMEDIUMBLOBbyte[]MEDIUMTEXTVARCHARjava.lang.StringLONGBLOBLONGBLOBbyte[]LONGTEXTVARCHARjava.lang.StringENUM('value1','value2',...)CHARjava.lang.StringSET('value1','value2',...)CHARjava.lang.String

对于boolean类型,在mysql数据库中,个人认为用int类型代替较好,对bit操作不是很方便,尤其是在具有web页面开发的项目中,表示0/1,对应java类型的Integer较好。在页面显示的时候,可以通过判断来显示相关数据。

我的概念中,mysql中的text字段应该是没有长度限制的,但是今天事实告诉我,text类型的长度是有限制的。其中mysqltext类型有64K长度限制的

新闻发布系统中的新闻内容的长度超过了64k,Text已经不适用,就换用了MEDIUMTEXT 他的长度为16777215 (2^24 - 1) 为256*64K=16M。

另外:一开始我换成了LongBlob ( 最大 4G),执行添加操作,还是无法插入。不知道是什么原因。待解决!


0 0
原创粉丝点击