ALPESH KOTHARI wrote:
> 
> Hello,
> 
> What you told is perfectly true. But  in my case it is
> a different story! When I read only characters then
> also it create the problem. To rectify it I have
> modified my program and now I am reading only few
> characters from the file(i.e. not going till end of
> file). Then also the same problem persists.
> 
> I have attatched  the java and test files for your
> reference. BTW I use Postgresql-6.5.1 and JDK1.2.

The problem is with the following snippet of your code:

==========8<==========8<==========
int len1=din.readByte();
System.out.println(len1);
byte[] lent=new byte[len1+2];
for(int i=0;i<(len1-3);i++)
{
  lent[i]=din.readByte();
  System.out.print(lent[i]);
  System.out.print(" ");
}
test1=new String(lent);
==========8<==========8<==========

You read a byte from the file.  The byte is 17.
Then you setup a byte array of length 19 [len1 + 2].
Then your for loop reads 14 [len1 - 3] bytes from the file and into the
array.
Then you build a String test1 out of that array.

You see, your String test1 is 19 characters long, the first 14
characters are filled with 'w', and the last 5 characters are NUL
('\0').

And that choked PostgreSQL!  Remove the NUL characters from the String
and everything will be fine.

-- 
Weiqi Gao
[EMAIL PROTECTED]


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to