参考一下,以前试验用的一段代码
File f = new File("D:\\SoftBack\\6.jpg");
int flen = (int)f.length();
System.out.println( flen );
FileInputStream in = new FileInputStream( f ); byte[] bb = new byte[(int)f.length()];
in.read( bb, 0, bb.length ); String sql0 = "insert into luxmtest values( 3, empty_blob() )";
String sql1 = "select データ from luxmtest where 通番=3 for update";
System.out.println( sql0 );
System.out.println( sql1 );
conn.setAutoCommit( false );
PreparedStatement stmt = conn.prepareStatement( sql0 );
System.out.println( stmt.execute() );
stmt.clearParameters();
stmt = conn.prepareStatement( sql1 );
rs = stmt.executeQuery();
if ( rs.next() ) {
System.out.println( "Step Update" );
oracle.sql.BLOB myblob = (oracle.sql.BLOB)rs.getBlob( 1 );
OutputStream write = myblob.getBinaryOutputStream();
write.write( bb, 0, bb.length );
write.close();
stmt.execute( "commit" );
}
File f = new File("D:\\SoftBack\\6.jpg");
int flen = (int)f.length();
System.out.println( flen );
FileInputStream in = new FileInputStream( f ); byte[] bb = new byte[(int)f.length()];
in.read( bb, 0, bb.length ); String sql0 = "insert into luxmtest values( 3, empty_blob() )";
String sql1 = "select データ from luxmtest where 通番=3 for update";
System.out.println( sql0 );
System.out.println( sql1 );
conn.setAutoCommit( false );
PreparedStatement stmt = conn.prepareStatement( sql0 );
System.out.println( stmt.execute() );
stmt.clearParameters();
stmt = conn.prepareStatement( sql1 );
rs = stmt.executeQuery();
if ( rs.next() ) {
System.out.println( "Step Update" );
oracle.sql.BLOB myblob = (oracle.sql.BLOB)rs.getBlob( 1 );
OutputStream write = myblob.getBinaryOutputStream();
write.write( bb, 0, bb.length );
write.close();
stmt.execute( "commit" );
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货