当前位置: 技术问答>java相关
如何通过jdbc将文件放到数据库里?
来源: 互联网 发布时间:2014-12-23
本文导语: | //gBlob 是oracle的BLOB类 用jdbc2 OutputStream outstream = gBlob.getBinaryOutputStream(); FileInputStream fin = new FileInputStream("/etc/config"); BufferedReader myInput = new BufferedReader(new InputStreamReader(fin)); while ((thisLine = myInput.readLin...
|
//gBlob 是oracle的BLOB类 用jdbc2
OutputStream outstream = gBlob.getBinaryOutputStream();
FileInputStream fin = new FileInputStream("/etc/config");
BufferedReader myInput = new BufferedReader(new InputStreamReader(fin));
while ((thisLine = myInput.readLine()) != null)
{
outstream.write(thisLine.getBytes(),0,thisLine.getBytes().length);
}
outstream.close();
((OracleResultSet) lRS).updateBLOB(key, gBlob);
OutputStream outstream = gBlob.getBinaryOutputStream();
FileInputStream fin = new FileInputStream("/etc/config");
BufferedReader myInput = new BufferedReader(new InputStreamReader(fin));
while ((thisLine = myInput.readLine()) != null)
{
outstream.write(thisLine.getBytes(),0,thisLine.getBytes().length);
}
outstream.close();
((OracleResultSet) lRS).updateBLOB(key, gBlob);