Hello!
Im having exactly the same error.
Code:
java.lang.UnsupportedOperationException: Blob may not be manipulated from creating session
Im using MySQL 4.1, Java 1.4 and Tomcat 4.1.
Im not using Hibernate for anything else that converting from FormFile to Blob type, as its specified in this lines:
Code:
public synchronized boolean subirArchivo(String nombre, FormFile file, int sector) throws Exception {
ConexionBD conn = new ConexionBD();
try{
/* The Hibernate class (in hibernate3.jar) converts to BLOB type the file that comes as FormFile */
Blob fileBlob = Hibernate.createBlob(file.getInputStream());
boolean r = GestorArchivo.getInstancia().registrarArchivo(conn, nombre, fileBlob, sector);
return r;
}catch (SQLException ex){
...
As you can see, I use the getInputStream() as a parameter of the createBlob() method, but I also get the exception if the parameter is "file.getFileData()". This didnt resolve the problem.
The exception is ocurring when im trying to insert the Blob in the PreparedStatement:
Code:
public synchronized boolean registrarArchivo(ConexionBD conn, String nombre, Blob file, int sector) throws SQLException {
String consulta = "INSERT INTO TArchivo VALUES (default, ?, ?, ?)";
try{
conn.setSQL(consulta);
conn.setString(1, nombre);
[b]conn.setBlob(2, file);[/b]
conn.setInt(3, sector);
}catch(Exception e){
e.printStackTrace();
}
...
That line in bold is where the app brakes down.
Please, if you could give some help I'll appreciate it a lot!