日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

long转string mybatis_Spring+Mybatis类型转换的问题,oracle数据库中有一个clob类型,怎样在查询以后转换为String类型?...

發布時間:2024/8/23 javascript 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 long转string mybatis_Spring+Mybatis类型转换的问题,oracle数据库中有一个clob类型,怎样在查询以后转换为String类型?... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

展開全部

首先你的思路就錯的,不可能轉換成string把大對象讀進byte[]

public byte[] function(Connection connection,所需參數) throws EMPException{

PreparedStatement ps = null;

ResultSet rs = null;

byte[] data = null;

try {

.....省略

while (rs.next()) {

oracle.sql.CLOB? clob= (oracle.sql.CLOB) rs.getClob("大對象的32313133353236313431303231363533e78988e69d8331333332623330字段名");

InputStream inStream =clob.getBinaryStream();

long nLen = clob.length();

int nSize = (int) nLen;

data = new byte[nSize];

inStream.read(data);

inStream.close();

connection.commit();

}

} catch (SQLException e) {

EMPLog.log(this.getClass().getName(), EMPLog.INFO, 0, e.toString());

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} finally {

try {

if (rs != null) {

rs.close();

rs = null;

}

if (ps != null) {

ps.close();

ps = null;

}

} catch (SQLException e) {

EMPLog.log(this.getClass().getName(), EMPLog.INFO, 0, e

.toString());

}

}

return data;

}

2.直接在頁面上將對象讀到頁面上

response.setContentType("image/jpg");

response.setHeader("Content-Transfer-Encoding","base64");

ServletOutputStream toClient = response.getOutputStream();

out.clear();

out = pageContext.pushBody();

ByteArrayInputStream in = new ByteArrayInputStream(data);

int len;

byte[] buf = new byte[1024];

while ((len = in.read(buf, 0, 1024)) != -1) {

toClient.write(buf, 0, len);

}

toClient.flush();

toClient.close();

%>

總結

以上是生活随笔為你收集整理的long转string mybatis_Spring+Mybatis类型转换的问题,oracle数据库中有一个clob类型,怎样在查询以后转换为String类型?...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。