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());
}
}
}