This discussion is archived
0 Replies Latest reply: Feb 15, 2012 8:06 PM by 904372 RSS

oracle.sql.BLOB and oracle.sql.STRUCT

904372 Newbie
Currently Being Moderated
I'm development a application in Java with oracle, to manage media files. When I try to insert into oracle , I have this problem "oracle.sql.BLOB cannot be cast to oracle.sql.STRUCT" , and I don't know what that can be ..

This is my code , please help with that.. If you have a smaple code of java and oracle to insert media , that will be a great help ..

public void loadDataFromStream(OracleConnection con)
{
try {
Statement s = con.createStatement();
OracleResultSet rs = (OracleResultSet)
s.executeQuery("select * from blobs where id='video2.avi' for update ");
String index = "";
while(rs.next())
{
index = rs.getString(1);
index+="1";
System.out.println("llego hasta aki");
// el error esta en esta linea de abajo ...
OrdVideo vidObj = (OrdVideo) rs.getCustomDatum(2, OrdVideo.getFactory());

//rs.getBfile(3);///

FileInputStream fStream = new FileInputStream("/home/jova/movie.avi");
vidObj.loadDataFromInputStream(fStream);
vidObj.getDataInFile("/home/jova/movie.avi");
fStream.close();
System.out.println(" getContentLength output : " +
vidObj.getContentLength());
OraclePreparedStatement stmt1 =
(OraclePreparedStatement) con.prepareCall("update blob_col set image = ? where id = " + index);
stmt1.setCustomDatum(1,vidObj);
stmt1.execute();
stmt1.close() ;
index+="1";


}

System.out.println("OK");


}
catch(Exception e) {
System.out.println("exception raised " + e);
System.out.println("load data from stream unsuccessful");
}
}

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points