logo       

Sponsor
FREE Network Mapping Tool for Microsoft® Office Visio® Professional 2007
Don't map your network by hand - let LANsurveyor Exx press for Microsoft Visio Professional 2007 automatically create network diagrams for you!

setBoolean with BIT column: msg#00163

db.postgresql.jdbc

Subject: setBoolean with BIT column

Hi,

I am using PostgreSQL 7.2 and have a column of type BIT that I am inserting into with a PreparedStatement. In reading the Javadoc for PreparedStatement, the setBoolean() method seems to be the correct way to set a parameter for a BIT datatype as the description for the method is:

"Sets the designated parameter to the given Java boolean value. The driver converts this to an SQL BIT value when it sends it to the database."

When I try this though, I get an error:

"cannot parse t as a binary digit"

In looking at the PreparedStatement's SQL, it seems to be constructing something like:

insert into myTable values('t')

which would explain the error message.

So, is this a bug in the JDBC driver in that it doesn't do the conversion to an SQL BIT value when sent to the database like the Javadoc says? If not, what is the correct way to set a parameter to a BIT value in a PreparedStatement?

I know I can probably use a BOOLEAN column and things will work fine, but I expected this to work using a BIT datatype.

Thanks,

Kevin


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster






Only community members can participate in forum threads. You must Register or log in to contribute.

<Prev in Thread] Current Thread [Next in Thread>
Sponsor
FREE Network Mapping Tool for Microsoft® OfficeVisio Professional 2007
Don't map your network by hand - let LANsurveyor Express for Microsoft Visio Professional 2007
automatically create network diagrams for you!
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | sitemap | advertise | OSDir is an inevitable website. super tiny logo