N
ncyqhhf
Unregistered / Unconfirmed
GUEST, unregistred user!
[?]我想把Connection对象转换成OracleConnection对象,这样后面的事情才好做,我写的代码如下:
<div align="center">ORACLE大文本的保存</div>
<% //初始化
conn = dbtool.connectDatabase("ok");
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
sql = "select * from hhf";
resultSet = stmt.executeQuery(sql);
//保存大文本
conn = DriverManager.getConnection("jdbcracle:thinlocalhost:1521:hhfora","maximo","maximo");
conn.setAutoCommit(false);
PreparedStatement pstmt = conn.prepareStatement("insert into hhf(code,blob) values(?,empty_blob())");
pstmt.setString(1,"66666");
pstmt.executeUpdate();
pstmt.close();
pstmt = conn.prepareStatement("select blob from hhf where code= ? for update");
pstmt.setString(1,"66666");
ResultSet rset = pstmt.executeQuery(sql);
if (rset.next()) blob = rset.getBlob("blob");
filename = "d://test.doc";
File f = new File(filename);
FileInputStream fin = new FileInputStream(f);
System.out.println("file size = " + fin.available());
pstmt = conn.prepareStatement("update hhf set blob=? where code='66666'");
******************
//OutputStream outhhf = blob.getBinaryOutputStream();
若用connection对象来连接数据,函数getBinaryOutputStream()就不能用,
用OracleConnection连接数据库,函数getBinaryOutputStream()就能同,
我不知道怎样把Connection对象连接转换成OracleConnection对象连接,望大 家能给我帮助,谢谢大家!!
*****************
//byte[] data = new byte[(int)fin.available()];
//fin.read(data);
//outhhf.write(data);
fin.close();
//outhhf.close();
//pstmt.setBlob(2,blob);
pstmt.setString(1,"66666");
pstmt.executeUpdate();
pstmt.close();
conn.commit();
conn.close();
%>
<div align="center">ORACLE大文本的保存</div>
<% //初始化
conn = dbtool.connectDatabase("ok");
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
sql = "select * from hhf";
resultSet = stmt.executeQuery(sql);
//保存大文本
conn = DriverManager.getConnection("jdbcracle:thinlocalhost:1521:hhfora","maximo","maximo");
conn.setAutoCommit(false);
PreparedStatement pstmt = conn.prepareStatement("insert into hhf(code,blob) values(?,empty_blob())");
pstmt.setString(1,"66666");
pstmt.executeUpdate();
pstmt.close();
pstmt = conn.prepareStatement("select blob from hhf where code= ? for update");
pstmt.setString(1,"66666");
ResultSet rset = pstmt.executeQuery(sql);
if (rset.next()) blob = rset.getBlob("blob");
filename = "d://test.doc";
File f = new File(filename);
FileInputStream fin = new FileInputStream(f);
System.out.println("file size = " + fin.available());
pstmt = conn.prepareStatement("update hhf set blob=? where code='66666'");
******************
//OutputStream outhhf = blob.getBinaryOutputStream();
若用connection对象来连接数据,函数getBinaryOutputStream()就不能用,
用OracleConnection连接数据库,函数getBinaryOutputStream()就能同,
我不知道怎样把Connection对象连接转换成OracleConnection对象连接,望大 家能给我帮助,谢谢大家!!
*****************
//byte[] data = new byte[(int)fin.available()];
//fin.read(data);
//outhhf.write(data);
fin.close();
//outhhf.close();
//pstmt.setBlob(2,blob);
pstmt.setString(1,"66666");
pstmt.executeUpdate();
pstmt.close();
conn.commit();
conn.close();
%>