Allow setObject(x,y,Types.BIT) if y is a Number & getObject() on bit columns

Started by Kim Hoabout 23 years ago5 messagespatches
Jump to latest
#1Kim Ho
kho@redhat.com

Problem:
- setObject(x,y,Types.BIT) throws an exception if y is a Number
- getObject() on a bit column will return null instead of True or False
Boolean objects

Fix:
- Added check in setObject() to check to that the Number has value==1.
If so, set to True. False otherwise. This seems to be consistent with
the rest of the code.
- Added BIT to JDBC datatype list

Cheers,

Kim

Attachments:

fixbits.difftext/x-patch; charset=UTF-8; name=fixbits.diffDownload+10-0
#2Kim Ho
kho@redhat.com
In reply to: Kim Ho (#1)
Re: Allow setObject(x,y,Types.BIT) if y is a Number &

On Wed, 2003-06-18 at 13:09, Kim Ho wrote:

Problem:
- setObject(x,y,Types.BIT) throws an exception if y is a Number
- getObject() on a bit column will return null instead of True or False
Boolean objects

Added Problem:
- Doesn't set bit columns

Fix:
- Added check in setObject() to check to that the Number has value==1.
If so, set to True. False otherwise. This seems to be consistent with
the rest of the code.
- Added BIT to JDBC datatype list

- Using way to set values in both boolean/bit type columns

It works now.

The following program works now:

Statement stmt = con.createStatement();
stmt.execute("Create Table bit_tab (b bit)");

PreparedStatement pstmt = con.prepareStatement("insert into bit_tab
values (?)");
pstmt.setBoolean(1,true);
pstmt.execute();

Sorry bout the delay.

Cheers,

Kim

#3Barry Lind
barry@xythos.com
In reply to: Kim Ho (#2)
Re: Allow setObject(x,y,Types.BIT) if y is a Number &

Kim,

Are you going to be submitting a patch for this?

thanks,
--Barry

Kim Ho wrote:

Show quoted text

On Wed, 2003-06-18 at 13:09, Kim Ho wrote:

Problem:
- setObject(x,y,Types.BIT) throws an exception if y is a Number
- getObject() on a bit column will return null instead of True or False
Boolean objects

Added Problem:
- Doesn't set bit columns

Fix:
- Added check in setObject() to check to that the Number has value==1.
If so, set to True. False otherwise. This seems to be consistent with
the rest of the code.
- Added BIT to JDBC datatype list

- Using way to set values in both boolean/bit type columns

It works now.

The following program works now:

Statement stmt = con.createStatement();
stmt.execute("Create Table bit_tab (b bit)");

PreparedStatement pstmt = con.prepareStatement("insert into bit_tab
values (?)");
pstmt.setBoolean(1,true);
pstmt.execute();

Sorry bout the delay.

Cheers,

Kim

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

#4Kim Ho
kho@redhat.com
In reply to: Barry Lind (#3)
Re: Allow setObject(x,y,Types.BIT) if y is a Number &

Oops. Forgot to attach it last time.

Show quoted text

On Mon, 2003-06-30 at 12:44, Barry Lind wrote:

Kim,

Are you going to be submitting a patch for this?

thanks,
--Barry

Kim Ho wrote:

On Wed, 2003-06-18 at 13:09, Kim Ho wrote:

Problem:
- setObject(x,y,Types.BIT) throws an exception if y is a Number
- getObject() on a bit column will return null instead of True or False
Boolean objects

Added Problem:
- Doesn't set bit columns

Fix:
- Added check in setObject() to check to that the Number has value==1.
If so, set to True. False otherwise. This seems to be consistent with
the rest of the code.
- Added BIT to JDBC datatype list

- Using way to set values in both boolean/bit type columns

It works now.

The following program works now:

Statement stmt = con.createStatement();
stmt.execute("Create Table bit_tab (b bit)");

PreparedStatement pstmt = con.prepareStatement("insert into bit_tab
values (?)");
pstmt.setBoolean(1,true);
pstmt.execute();

Sorry bout the delay.

Cheers,

Kim

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Attachments:

fixbits.difftext/plain; charset=UTF-8; name=fixbits.diffDownload+19-12
#5Dave Cramer
pg@fastcrypt.com
In reply to: Kim Ho (#1)
Re: Allow setObject(x,y,Types.BIT) if y is a Number &

Patch applied,

thanks,
Dave
On Wed, 2003-06-18 at 13:09, Kim Ho wrote:

Problem:
- setObject(x,y,Types.BIT) throws an exception if y is a Number
- getObject() on a bit column will return null instead of True or False
Boolean objects

Fix:
- Added check in setObject() to check to that the Number has value==1.
If so, set to True. False otherwise. This seems to be consistent with
the rest of the code.
- Added BIT to JDBC datatype list

Cheers,

Kim

______________________________________________________________________

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

--
Dave Cramer <Dave@micro-automation.net>