I am unable to transfer data from oracle(DB) to postgressql(DB).
This is the table structure in oracle database
create table user_details
(
USR_ID NOT NULL VARCHAR2(13),
ADDR NOT NULL VARCHAR2(150),
USR_PHOTO LONG RAW
}
This is the table structure in postgres
CREATE TABLE tb_cd_usrinfo
(
usr_id character varying(13) NOT NULL,
addr character varying(150) NOT NULL,
usr_photo bytea,
CONSTRAINT pk_tb_cd_usrinfo PRIMARY KEY (usr_id )
)
i tried to create a transformation using a user defined java class to write LONG RAW to file.. and it is working fine.
this is the following code snippet
import java.io.*;
import java.sql.*;
import java.util.*;
import java.math.*;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
Connection con=null;
Statement st=null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbcracle:thin:@localhost:1521
ra", "EGCTR", "egctr");
st=con.createStatement();
ResultSet rs=st.executeQuery("SELECT usr_photo FROM user_details");
byte outBytes[];
while(rs.next()){
outBytes=rs.getBytes(1);
File f = new File("C:\\test.jpeg");
if (!f.exists()){
f.createNewFile();
}
FileOutputStream fos = new FileOutputStream(f);
BufferedOutputStream bos = new BufferedOutputStream(fos);
bos.write(outBytes);
bos.flush();
bos.close();
fos.write(outBytes);
fos.flush();
fos.close();
}
return true;
}catch (Exception e){
return false;
}finally{
if(con!=null)
con.close();
if(st!=null)
st.close();
}
}
I need help to transfer the data from oracle to postgressql..
Thanks in Advance,
Venkat


racle:thin:@localhost:1521
Reply With Quote