第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

可以打印出圖片的大小來,測(cè)試的時(shí)候是綠色的條, 但是數(shù)據(jù)庫里面沒有任何數(shù)據(jù)。

代碼如下:

@Test

public void writePicture() throws Exception{

Student student5 = new Student(005, "Naruto", "男", new Date(), "火之國(guó)");

File pictureFile = new File("c:"+File.separator+"zhang"+File.separator+"Naruto.jpg");

//System.out.println(pictureFile);

InputStream input;

try {

input = new FileInputStream(pictureFile);

Blob image = Hibernate.getLobCreator(session).createBlob(input, input.available());

System.out.println("照片長(zhǎng)度:"+image.length()); ? //這時(shí)候打印出的數(shù)據(jù)是:10505

student5.setPicture(image);

session.save(student5);

System.out.println("保存成功!");

} catch (FileNotFoundException e) {

System.out.println("圖片文件沒找到");

e.printStackTrace();

}catch (IOException e) {

System.out.println("Bolb對(duì)象創(chuàng)建失敗,input.available()錯(cuò)誤!");

e.printStackTrace();

}

}

這時(shí)候測(cè)試時(shí),是綠色的條,但是數(shù)據(jù)庫里面沒有數(shù)據(jù),其他id什么的數(shù)據(jù)都沒存進(jìn)去?這是為什么呢?



正在回答

1 回答

謝謝大家 ?解決了。

得加上這個(gè):

session.doWork(new Work() {

@Override

public void execute(Connection connection) throws SQLException {

connection.setAutoCommit(true);

}

});

都糊涂了?。?!好低級(jí)的錯(cuò)誤,吃飯回來后才看到。

2 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

可以打印出圖片的大小來,測(cè)試的時(shí)候是綠色的條, 但是數(shù)據(jù)庫里面沒有任何數(shù)據(jù)。

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)