标题:oracle操作图片遇到的问题
取消只看楼主
bjgs2004
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2007-3-18
 问题点数:0 回复次数:0 
oracle操作图片遇到的问题
我是oracle的初学者,我在利用oracle对图片操作时候遇到了一个问题,运行后,光标一直在闪,没反应.好像一直在往oracle写数据,没有结束似的.请各位帮我指点一下.表和java代码如下:

picture表:(id number,
pic blob)

程序代码:
import java.sql.*;
import java.io.*;
public class sqlDo
{
public static void main(String args[])
{
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String sqlStr;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException e)
{
System.err.println(e.getMessage());
}
try
{
String url="jdbc:oracle:thin:@localhost:1521:oradb";
String user="scott";
String password="tiger";
conn=DriverManager.getConnection(url,user,password);
conn.setAutoCommit (false);
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);

File filename=new File("D:\\Program Files\\Xinox Software\\JCreatorV3\\workplace\\db\\su.jpg");
FileInputStream fin=new FileInputStream(filename);

sqlStr="insert into picture values(?,?)";
PreparedStatement prestmt=conn.prepareStatement(sqlStr);
prestmt.setBinaryStream(2,fin,(int)filename.length());
prestmt.setInt(1,1);
prestmt.execute();

rs=stmt.executeQuery("select * from picture");
rs.absolute(1);
InputStream in=rs.getBinaryStream(2);
FileOutputStream fout=new FileOutputStream("D:\\Program Files\\Xinox Software\\JCreatorV3\\workplace\\db\\fsu.jpg");
byte[] b=new byte[0x7a120];
while ((in.read(b))!=-1)
{
fout.write(b);
}

fout.close();
fin.close();
in.close();
conn.close();
stmt.close();
prestmt.close();
rs.close();
}
catch(Exception ce)
{
System.err.println(ce.getMessage());
}
}
}
搜索更多相关主题的帖子: oracle 
2007-03-24 20:18



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-126492-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.330291 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved