pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Problem with boolean type
3+ messages / 3 participants
[nested] [flat]

* Problem with boolean type
@ 2004-10-07 14:47  Johann Robette <jrobette@onyme.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Johann Robette @ 2004-10-07 14:47 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; +Cc: pgsql-jdbc

Hi,

I'm using Postgres 8.0 beta 3 and the appropriate JDBC Driver.

I use EJB to create a record in a table containing a Boolean field
"answered".
The EJB method expects a Boolean object so I pass new Boolean(false) in
order to create it as false.

But I get the following error : 
java.sql.SQLException: ERROR: column "answered" is of type boolean but
expression is of type text


Any help will be greatly appreciated.

JR





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [JDBC] Problem with boolean type
@ 2004-10-07 15:19  Kris Jurka <books@ejurka.com>
  parent: Johann Robette <jrobette@onyme.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Kris Jurka @ 2004-10-07 15:19 UTC (permalink / raw)
  To: Johann Robette <jrobette@onyme.com>; +Cc: pgsql-general@postgresql.org; pgsql-jdbc



On Thu, 7 Oct 2004, Johann Robette wrote:

> I use EJB to create a record in a table containing a Boolean field
> "answered".
> The EJB method expects a Boolean object so I pass new Boolean(false) in
> order to create it as false.
> 
> But I get the following error : 
> java.sql.SQLException: ERROR: column "answered" is of type boolean but
> expression is of type text

I don't see how that could be happening.  The attached test works fine for 
me and exercises every way I see to set a boolean.  Perhaps the EJB is 
internally converting this to a setString() call?  Could you investigate 
more into what actual driver calls are being made?

Kris Jurka

Attachments:

BoolTest.java (text/plain, 990B) download import java.sql.*; public class BoolTest { public static void main(String args[]) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5750/jurka","jurka",""); Statement stmt = conn.createStatement(); stmt.execute("CREATE TEMP TABLE tt (ans bool)"); stmt.close(); PreparedStatement pstmt = conn.prepareStatement("INSERT INTO tt (ans) VALUES (?)"); pstmt.setObject(1, new Boolean(false)); pstmt.executeUpdate(); pstmt.setBoolean(1, false); pstmt.executeUpdate(); pstmt.setObject(1, new Boolean(false), Types.BIT); pstmt.executeUpdate(); pstmt.setObject(1, new Boolean(false), Types.BOOLEAN); pstmt.executeUpdate(); pstmt.close(); stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT ans FROM tt"); while (rs.next()) { System.out.println(rs.getBoolean(1)); } rs.close(); stmt.close(); conn.close(); } }
^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: Problem with boolean type
@ 2004-10-07 20:10  Oliver Jowett <oliver@opencloud.com>
  parent: Johann Robette <jrobette@onyme.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Oliver Jowett @ 2004-10-07 20:10 UTC (permalink / raw)
  To: Johann Robette <jrobette@onyme.com>; +Cc: pgsql-jdbc

Johann Robette wrote:

> I'm using Postgres 8.0 beta 3 and the appropriate JDBC Driver.

What is the "appropriate JDBC driver"?

> I use EJB to create a record in a table containing a Boolean field
> "answered".
> The EJB method expects a Boolean object so I pass new Boolean(false) in
> order to create it as false.
> 
> But I get the following error : 
> java.sql.SQLException: ERROR: column "answered" is of type boolean but
> expression is of type text

Do you have access to the code that is calling the JDBC driver? Can you 
show us that code?

-O



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-10-07 20:10 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-10-07 14:47 Problem with boolean type Johann Robette <jrobette@onyme.com>
2004-10-07 15:19 ` Kris Jurka <books@ejurka.com>
2004-10-07 20:10 ` Oliver Jowett <oliver@opencloud.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox