setBlob and classCastException [message #91286] |
Tue, 02 July 2002 13:00 |
Sandro
Messages: 6 Registered: March 2002
|
Junior Member |
|
|
Hi,
Can somebody help me to make my code work !? I don't found any place that shows an easy solution to write an java.sql.Blob to Oracle database.
I'm trying the code:
...
Connection con = ds.getConnection();
PreparedStatement pst = con.prepareStatement("insert into teste (id, thumbnail) values (?, ?)");
pst.setInt(1, Integer.parseInt(strID));
pst.setBlob(2, blob);
pst.executeUpdate();
...
Where blob is an object from inner class br.com.spectrum.MultipartRequest$FileBlob that implements the interface java.sql.Blob. strID is some parseable integer.
When I compile and run the code, I obtain the following exception stack trace:
java.lang.ClassCastException: br.com.spectrum.MultipartRequest$FileBlob
at oracle.jdbc.driver.OraclePreparedStatement.setBlob(OraclePreparedStatement.java:1819)
at com.evermind.sql.FilterPreparedStatement.setBlob(FilterPreparedStatement.java:437)
at com.evermind.sql.FilterPreparedStatement.setBlob(FilterPreparedStatement.java:437)
at com.evermind.sql.FilterPreparedStatement.setBlob(FilterPreparedStatement.java:437)
at com.evermind.sql.FilterPreparedStatement.setBlob(FilterPreparedStatement.java:437)
at teste.ThumbServlet.uploadFile(ThumbServlet.java:55)
at teste.ThumbServlet.service(ThumbServlet.java:29)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletReque
stDispatcher.java:684)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(Ser
vletRequestDispatcher.java:269)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpReques
tHandler.java:735)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.ja
va:243)
at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)
I'm making an servlet that receives an "multipart/form-data" request, and saves the uploaded file into some Oracle database, in the table teste.
Thanks.
|
|
|
|