ºìÁªLinuxÃÅ»§
Linux°ïÖú

OracleµÄvarchar2(4000)²åÈ뺺×Ö¹ý³¤

·¢²¼Ê±¼ä:2008-04-28 00:02:03À´Ô´:ºìÁª×÷Õß:yichfot
ÔÚʹÓÃoracleʱ£¬Èç¹ûÔÚÒ»¸övarchar2(4000)µÄ×Ö¶ÎÉϲåÈëµÄ×Ö·û¹ý³¤£¨Ò»°ãÖ»ÄܲåÈë666¸öºº×Ö£¬ÊÓ×Ö·û¼¯²»Í¬»áÓÐËù²»Í¬£©£¬»áµ¼ÖÂʧ°Ü£¬¾ßÌ屨´í»áÒòÇý¶¯°æ±¾²»Í¬¶ø²»Í¬¡£

Ô­ÒòÒ»£º

666 ºº×ÖËùÓõıàÂëÀï (¿ÉÄÜÊÇ UTF8) ÿ¸ö×ÖÕ¼ÁË 3 bytes£¬µ±´æµÄʱºò, ûÓÐ×÷ºÃ charset-encoding µÄת»»£¬Ôì³ÉÄãµÄÿ¸ö byte ±»µ±³ÉÊÇ java µÄÒ»¸ö char (2 bytes) À´´æ£¬Õâʱ£¬Ã¿¸öºº×ÖÒªÓà 3x2=6 bytes ´æ½ø oracle ÖУ¬ËùÒÔ×î¶àÖ»ÄÜ´æµ½ 4000/6=666 ×Ö¡£

Ô­Òò¶þ£º
ÕâÊǸöOracleJDBCÎÊÌâ¡£Ò»°ãÖ±½ÓÓÃps.setString()ÉèÖÃ×Ö·û´®Êý¾Ýʱ£¬OracleµÄJDBCÇý¶¯»á½«ÖÐÎÄת»»Îª2×Ö½Ú»ò3×Ö½Ú£¬²»¹Ì¶¨µÄ£¬Òò´Ë¾­³£»áÔ½½ç¡£Èç¹û¸ÄΪps.setCharacterStream()¾ÍÊǹ̶¨µÄÿ¸öÖÐÎÄÁ½¸ö×Ö½Ú¡£

½â¾ö°ì·¨£º

·½·¨Ò»£º

ʹÓÃps.setCharacterStream()²åÈë¶à¸ö×Ö·û£º

Ô­À´µÄ´úÂë
//ps.setString(i, ((String) parameter));

String s = (String) parameter;
ps.setCharacterStream(i, new StringReader(s), s.length());

·½·¨¶þ£º

²»ÓÃPreparedStatement£¬¶øÖ±½Ó×é³ÉsqlÓï¾ä²åÈë¡£

·½·¨Èý£º

ÓÃCLOB×Ö¶ÎÀ´½â¾ö¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ