¶ÔoracleÊý¾Ý¿âÖÐCLOB×ֶεÄÏà¹Ø²Ù×÷
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* ´Ë´¦²åÈëÀàÐÍ˵Ã÷¡£
* ´´½¨ÈÕÆÚ£º(2001/11/30 14:55:06)
* @author£ºzhubin
*/
public class BLOBUtil {
/**
* ¹¦ÄÜ˵Ã÷£º±àÂ뷽ʽ
* ȡֵ·¶Î§£º
* ÒÀÀµÊôÐÔ£º
* ×îºóÐÞ¸Äʱ¼ä£º(2002-2-27 15:30:40)
*/
private static String codeSet;
/**
* ´Ë´¦²åÈë·½·¨ËµÃ÷¡£
* ´´½¨ÈÕÆÚ£º(2001/11/30 14:58:15)
* @return java.lang.String
* @param result java.sql.ResultSet
* @param index int
*/
public static String readBLOB(ResultSet result, int index) throws IOException,
SQLException
{
String strValue = null;
// ¶ÔÓÚSQL NULL£¬·½·¨getBinaryStream½«·µ»Ønull
InputStream in = result.getBinaryStream(index);
if (in == null) {
return "";
}
byte[] ba = new byte[8192];
ByteArrayOutputStream b = new ByteArrayOutputStream();
int i;
while((i = in.read(ba)) != -1){
b.write(ba, 0, i);
}
try{
strValue = b.toString(codeSet);
}catch(Exception e){
strValue = b.toString();
}
return strValue;
}
/**
* ´Ë´¦²åÈë·½·¨ËµÃ÷¡£
* ´´½¨ÈÕÆÚ£º(2001/11/30 14:59:52)
* @return java.lang.String
* @param result java.sql.ResultSet
* @param name java.lang.String
*/
public static String readBLOB(ResultSet result, String name) throws IOException,
SQLException
{
String strValue;
// ¶ÔÓÚSQL NULL£¬·½·¨getBinaryStream½«·µ»Ønull
InputStream in = result.getBinaryStream(name);
if (in == null) {
return "";
}
byte[] ba = new byte[8192];
ByteArrayOutputStream b = new ByteArrayOutputStream();
int i;
while((i = in.read(ba)) != -1){
b.write(ba, 0, i);
}
try{
strValue = b.toString(codeSet);
}catch(Exception e){
strValue = b.t
Ïà¹ØÎĵµ£º
Óαê
Ö¸ÏòÉÏÏÂÎÄÇøÓòµÄ¾ä±ú»òÖ¸Õë
ÓαêÔÚ·þÎñÆ÷¶Î´æ´¢
ÊôÐÔ
%NOTFOUND ûÓÐÕÒµ½½á¹û»òûÓвÙ×÷³É¹¦
%FOUND ÕÒµ½½á¹û»ò²Ù×÷³É¹¦
%ROWCOUNT ÓαêÓ°ÏìµÄÐÐÊý
%ISOPEN ÓαêÊÇ·ñ´ò¿ª Ò ......
Íⲿ±íÊÇÖ¸²»ÔÚÊý¾Ý¿âÖÐµÄ±í£¬Èç²Ù×÷ϵͳÉϵÄÒ»¸ö°´Ò»¶¨¸ñʽ·Ö¸îµÄÎı¾Îļþ»òÕ߯äËûÀàÐÍµÄ±í¡£Õâ¸öÍⲿ±í¶ÔÓÚOracleÊý¾Ý¿âÀ´Ëµ£¬¾ÍºÃÏñÊÇÒ»ÕÅÊÓͼ£¬ÔÚÊý¾Ý¿âÖпÉÒÔÏñÊÔͼһÑù½øÐвéѯµÈ²Ù×÷¡£Õâ¸öÊÔͼÔÊÐíÓû§ÔÚÍⲿÊý¾ÝÉÏÔËÐÐÈκεÄSQLÓï¾ä£¬¶ø²»ÐèÒªÏȽ«Íⲿ±íÖеÄÊý¾Ý×°ÔØ½øÊý¾Ý¿âÖС£²»¹ýÐèҪעÒâÊÇ£¬ÍⲿÊý¾Ý±í¶¼ÊÇÖ»¶ ......
LENGTH calculates length using characters as defined by the input character set.
LENGTHB uses bytes instead of characters.
VSIZE returns the number of bytes in the internal representation of expr.
LENGTHC uses Unicode complete characters.
LENGTH2 uses UCS2 codepoints.
......
ÖйúµçÁ¦ÐÐҵĿǰÕýÔÚ¾Àúמ޴óµÄ±ä»¯£º´Ó¹ú¼Ò°ìµçµ½ÆóÒµ°ìµç£¬ÐγÉÁ˶à¼Ò¾ºÕù°ìµçµÄ¸ñ¾Ö£»³§Íø·Ö¿ª¡¢¾º¼ÛÉÏÍø£¬´Ó¼Æ»®µ½Êг¡×ª¹ì£¬ÒýÈë¶àÖÖ¾¼Ã³É·Ö£»´ÓµØÓòÐÔ·ÖÉ¢¹©µçÏò´óµçÍø·¢Õ¹£»´ÓÕþÆó²»·Öµ½ÕþÆó·Ö¿ª¡£ÕâЩ±ä»¯£¬Ê¹ÖйúµÄµçÁ¦ÐÐÒµ¾ÊÜ×ÅǰËùδÓеÄѹÁ¦¡£
Ò»·½Ã棬2003Äê¹úÄڵķ¢µçÆóÒµÖØÐ¸Ä×é£ ......