oracleblob类型对应sqlserver中的p_w_picpath类型

/**
*@paramsourceConn源数据库连接
*@paramtargetConn目标数据库连接

*/
publicvoidcopyFile{

ConnectionsourceConn=getOraclCon();

Statements=null;

ConnectiontargetConn=getSqlserverCon();

ResultSetrs=null;
PreparedStatementps=null;
try{
Stringsql="select*fromFM_BLOB";
s=sourceConn.createStatement();
rs=s.executeQuery(sql);
ps=targetConn.prepareStatement("insertintoFILE(ID,FILE_NAME,FILE_TYPE,FILE_SIZE,FILE_DATA)values(?,?,?,?,?)");
while(rs.next()){
ps.setInt(1,rs.getInt("ID"));
ps.setString(2,rs.getString("FILE_NAME"));
ps.setString(3,rs.getString("FILE_TYPE"));
intsize=rs.getInt("FILE_SIZE");
ps.setFloat(4,size);
InputStreaminputStream2=rs.getBinaryStream("FILE_DATA");
InputStreaminputStream=rs.getBinaryStream("FILE_DATA");
intlen=0;
byte[]b=newbyte[1024];
intj=0;
while((len=inputStream.read(b,0,b.length))!=-1){
j+=len;
}
ps.setBinaryStream(5,inputStream2,j);
ps.executeUpdate();

}
}catch(Exceptione){
e.printStackTrace()
}
finally{
ps.close();

s.close();

rs.close();

sourceConn.close();

targetConn.close();

}

}

//oracle数据库连接

publicConnectiongetOraclCon(){

Stringdriver="oracle.jdbc.driver.OracleDriver";
Stringurl="jdbc:oracle:thin:@loaclhost:1521:orcl";
Stringid="ora
Stringpwd="123456";
Connectionconn=null;
try{
Class.forName(driver);
conn=DriverManager.getConnection(url,id,pwd);
}catch(Exceptione){
e.printStackTrace();
}
returnconn;

}

//sqlServer数据库连接

publicConnectiongetSqlserverCon(){

Stringdriver="com.microsoft.sqlserver.jdbc.SQLServerDriver";
Stringurl="jdbc:sqlserver://localhost:1433;DatabaseName=tempdb";
Stringid="sa";
Stringpwd="123456";
Connectionconn=null;
try{
Class.forName(driver);
conn=DriverManager.getConnection(url,id,pwd);
}catch(Exceptione){
e.printStackTrace();
}
returnconn;

}