Thread: JBuilder4

JBuilder4

From
Catalin CIOCOIU
Date:
    I have installed the driver JDBC for postgres in JBuilder.
    I have a problem when I use JDBC Explorer. I can't see the folder
TABLES when I open a Postgres Database. I see other folders (procedures
etc). The querys works fine.
Can somebody help me ?

Blobs and length +- 1

From
Philip Crotwell
Date:
Hi

I am using Blobs with jdbc and postgres7.0.3 and noticed that my blobs
were coming out of the database 1 byte shorter than they went in! The
problem was that I was using
byte[] b = blob.getBytes(1, (int)blob.length());
instead of
byte[] b = blob.getBytes(0, (int)blob.length());

But the javadocs for java.sql.Blob says, that the position is 1 based:


Returns as an array of bytes part or all of the BLOB value that this Blob
object designates. The byte array contains up to length consecutive bytes
starting at position pos.
     Parameters:
         pos - the ordinal position of the first byte in the BLOB value to
be extracted; the first byte is at position 1
         length - is the number of consecutive bytes to be copied


It seems to me that this says that getBytes(1, length) should be the
entire blob instead of all but the first byte.

Is this a postgres jdbc bug, or am I misreading the javadocs?

The fix would be to subtract one, ie:
    public byte[] getBytes(long pos,int length) throws SQLException {
        lo.seek((int)pos-1,LargeObject.SEEK_SET);
        return lo.read(length);
    }

thanks,
PHilip

PS For what it is worth and if it is the case, I think it is a pretty dumb
thing for sun to make blob byte arrays 1 based. I would actually prefer 0
based, but being compatible is probably more important.



Re: JBuilder4

From
Peter Mount
Date:
At 10:31 01/03/01 +0100, Catalin CIOCOIU wrote:
>         I have installed the driver JDBC for postgres in JBuilder.
>         I have a problem when I use JDBC Explorer. I can't see the folder
>TABLES when I open a Postgres Database. I see other folders (procedures
>etc). The querys works fine.
>Can somebody help me ?

What version of JDBC are you using?

The current beta works fine using JBuilder 4 (which I'm now using as the
IDE for developing the driver).

Peter


Re: Blobs and length +- 1

From
Peter Mount
Date:
At 09:31 01/03/01 -0500, Philip Crotwell wrote:

>Hi
>
>I am using Blobs with jdbc and postgres7.0.3 and noticed that my blobs
>were coming out of the database 1 byte shorter than they went in! The
>problem was that I was using
>byte[] b = blob.getBytes(1, (int)blob.length());
>instead of
>byte[] b = blob.getBytes(0, (int)blob.length());
>
>But the javadocs for java.sql.Blob says, that the position is 1 based:

Whoops. I'll double check. I probably was too happy to finally get the
streaming to work that this one crept in ;-)

>Returns as an array of bytes part or all of the BLOB value that this Blob
>object designates. The byte array contains up to length consecutive bytes
>starting at position pos.
>      Parameters:
>          pos - the ordinal position of the first byte in the BLOB value to
>be extracted; the first byte is at position 1
>          length - is the number of consecutive bytes to be copied
>
>
>It seems to me that this says that getBytes(1, length) should be the
>entire blob instead of all but the first byte.
>
>Is this a postgres jdbc bug, or am I misreading the javadocs?

No a bug. The rule with JDBC is: Everything starts with 1.

I'll fix it in tomorrows commit.


>The fix would be to subtract one, ie:
>     public byte[] getBytes(long pos,int length) throws SQLException {
>         lo.seek((int)pos-1,LargeObject.SEEK_SET);
>         return lo.read(length);
>     }
>
>thanks,
>PHilip
>
>PS For what it is worth and if it is the case, I think it is a pretty dumb
>thing for sun to make blob byte arrays 1 based. I would actually prefer 0
>based, but being compatible is probably more important.

Same here ;-)

Peter


Re: JBuilder4

From
Catalin CIOCOIU
Date:
I use jdbc7.0-1.2.jar !

Peter Mount wrote:
>
> At 10:31 01/03/01 +0100, Catalin CIOCOIU wrote:
> >         I have installed the driver JDBC for postgres in JBuilder.
> >         I have a problem when I use JDBC Explorer. I can't see the folder
> >TABLES when I open a Postgres Database. I see other folders (procedures
> >etc). The querys works fine.
> >Can somebody help me ?
>
> What version of JDBC are you using?
>
> The current beta works fine using JBuilder 4 (which I'm now using as the
> IDE for developing the driver).
>
> Peter