• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insert BLOB into a DB

 
Esteban Cairol
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

Im having a problem when trying to insert a blob type variable into the Data Base (MySQL 4.1). In fact, the exception triggers when the the p.setBlob() is done, where p is the PreparedStatement.

Some details you may want to know before read the error:
- Im using Hibernate to convert from FormFile to Blob. I didn't install Hibernate complete on my application, in fact, I just put the hibernate3.jar on the classpath to use this converting function. Its not used for anything else.
- Im using Java 4.1 and Apache Tomcat 4.1

The exception is this:






The code:

Method that creates the connection.


Function registrarArchivo (this is like.. "uploadFile")



That line with the * is where the app is breaking.

Finally, the setBlob method:




Please, if you could help me I'll appreciate it a lot..!
Thanks!
[ July 14, 2007: Message edited by: Esteban Cairol ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Esteban,
I'm going to move this to our Hibernate forum. Since the stack trace has Hibernate classes in it, I think people will be more likely to know the answer there.
 
Esteban Cairol
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
Esteban,
I'm going to move this to our Hibernate forum. Since the stack trace has Hibernate classes in it, I think people will be more likely to know the answer there.


Ok.. thanks!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Im using Hibernate to convert from FormFile to Blob. I didn't install Hibernate complete on my application, in fact, I just put the hibernate3.jar on the classpath to use this converting function. Its not used for anything else

Hmm. Sounds like a dodgy thing to do - there's probably more going on in the Hibernate class than a simple bean. Could you not just use a byte array?
 
Esteban Cairol
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:

Hmm. Sounds like a dodgy thing to do - there's probably more going on in the Hibernate class than a simple bean. Could you not just use a byte array?


Thanks for answering Paul.
What I have to do is to insert a file into the Data Base. It could be an image, or other type of files..

I haven't found another way to do that than using a byte array (I mean, a BLOB). If you know other way to do that, it would be great.

Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic