UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » Java
  • » Plz help me in solution for this error......

#1 2006-07-18 01:05 PM

surya_jc
Member
Registered: 2006-07-18
Posts: 8

Re: Plz help me in solution for this error......

Offline

#2 2006-07-21 10:27 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: Plz help me in solution for this error......

You are attempting to directly to cast from a base Object to a Blob... and you really cannot do that...  simply because the object returned by a call to getContent( ) is NOT a Blob... and not a child from Blob...

Other notes...

Blobs normally take clusters / arrays of bytes etc. as their input... so whatever you get from getContent( ) has to be serialized ( after all - its a full blow object of the class type determined from the returned mime type ) and then that needs to be fed into the Blob...

Ah - but there is a potential problem... there is nothing that REQUIRES the object type returned by getContent( ) to be serializable... so um - how do you convert the darn thing into something which can be stored in an array?!

So an alternative to what you are doing might be to simply grab the input stream - feed it into a byte array - then stuff that into the Blob... and read out / instantiate via a factory as needed...

Michael


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#3 2006-07-21 10:46 AM

surya_jc
Member
Registered: 2006-07-18
Posts: 8

Re: Plz help me in solution for this error......

Offline

#4 2006-07-21 01:01 PM

surya_jc
Member
Registered: 2006-07-18
Posts: 8

Re: Plz help me in solution for this error......

Offline

#5 2006-07-21 07:38 PM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: Plz help me in solution for this error......

As I had mentioned in the last message... there is nothing that says the object type returned by the getContent( ) call has to be serializable...

In fact, it is allowed to do things such as return just a stream type instead of the final object itself... when using a URLConnection for an HTTP URL thats exactly what you get... you can verify this by doing a print( ob )

You don't want to try and store a producer or stream... so... once you do getContent... verify that it is a input stream type ( isinstance etc. )... then read data into your byte array while the stream.available() != 0... take THAT byte array and store it...

If you do this then for a regular html page you should have read the start and stop <html> tags and everything in between... for a pdf you should get the binary file itself... and so forth...

Michael


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#6 2006-07-24 08:05 AM

surya_jc
Member
Registered: 2006-07-18
Posts: 8

Re: Plz help me in solution for this error......

Offline

#7 2006-07-24 08:52 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: Plz help me in solution for this error......

Well...

I guess I will answer you on this forum... its my favorite... and my replies elsewhere don't seem to have detered you... lol

So you didn't provide a lot of information... so the following is a guess based on common errors I have seen...

Folks who see that particular error seem to focus on thinking that somehow they are 'missing' a column in the database...  and that is why they are having problems... but the truth is typically its the exact opposite situation...

To explain...

You have a database... you have a table... you have an int column... you have a blob column... you have it set up to generate a unique id for each row in the table... that last item is probably the issue ( do you have an unique id generated ? )...

The thing is that the automatic ( unique ) id is assigned to column 1... the int would be column 2... the blob would be column 3...  so explicit assignments like you have would cause a fault i.e. you are trying to set the id to an int of your own chosing when the db thinks that it is going to be performing the task... and the blob is being assigned to an int...!

So thats just a guess... but try changing the indexes by incrementing them by 1... see if the error clears up / vanishes...

Michael


P.S. Please please please... here and elsewhere... if there is a code block option, use it...  you are hurting my brain... ;-)


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

#8 2006-07-24 12:44 PM

surya_jc
Member
Registered: 2006-07-18
Posts: 8

Re: Plz help me in solution for this error......

Offline

#9 2006-07-27 07:17 AM

surya_jc
Member
Registered: 2006-07-18
Posts: 8

Re: Plz help me in solution for this error......

Offline

  • Index
  • » Java
  • » Plz help me in solution for this error......

Board footer

Powered by FluxBB