/**
* 向表中插入图片
*
* @param path图片所在的路径
* @return 整形 判断成功或失败
*/
public int insertImage(String path) throws Exception {
int i = 0;
Statement st = null;
ResultSet rs = null;
conn=this.getConnection();
conn.setAutoCommit(false);//设置数据库为不自动提交,必须的一步
st = conn.createStatement();
//先插入一个空对象,这里我调用了Empty_BLOB()函数
i = st.executeUpdate("insert into image (id,image) values (seq1.nextval,Empty_BLOB())");
//以行的方式锁定
rs = st.executeQuery("select image from image where id=(select max(id) from image) for update");
if (rs.next()) {
//得到流
oracle.sql.BLOB blob = (oracle.sql.BLOB) rs.getBlob(1);
//从得到的低级流构造一个高级流
PrintStream ps = new PrintStream(blob.getBinaryOutputStream());
BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(path));
byte[] buff = new byte[1024];
int n = 0;
//从输入到输出
while ((n = bis.read(buff)) != -1) {
ps.write(buff, 0, n);