我的程序,环境eclipse3.1+oracle9i+xp
Oracle定义了一个表为test(num(NUMBER),WENHAO1(VARCHAR(2)),DESCRIPTION(BLOB)存放XML文件)
public static void main(String[] args) {

ResultSet rsO = null;
Connection connO =null;
Statement stmtO = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url = "jdbc:oracle:thin:@localhost:1521:tstapp";
String user = "system";
String password = "system";
String sql = "select  t.num,t.WENHAO1,t.DESCRIPTION from test t";
connO = DriverManager.getConnection(url,user,password);
stmtO = connO.createStatement();
rsO = stmtO.executeQuery(sql);
byte []buf = new byte[1024];
String s = new String();
while(rsO.next())
{
InputStream in=rsO.getBinaryStream(3);
InputStreamReader is = new InputStreamReader(in);

in.read(buf);
String cn = new String(buf);
System.out.println(cn);


        } catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
这样中文打印出来为乱码,而且我想取得InputStream中数据的长度,但InputStream为提供相关的方法,InputStream.available()方法是非阻塞的,因此用这个方法总是返回0.