Reputation: 257
i created a Derby DB table from within Netbeans 7.1, using the 'create table' window inside the IDE. one of the columns need to be of a bit type (i want to hold boolean data - 1/0). when i added that column, i used 'char for bit data' as its type. when i add lines using the IDE's 'insert records' window, the lines are added, but when i try to add lines using SQL commands (which how i'll eventually add data to the table from within my java code), it always throws an error. if i try INSERT INTO APP.TEMP (ID, BOOL) VALUES (3, 0)
the response is Columns of type 'CHAR () FOR BIT DATA' cannot hold values of type 'INTEGER'.
and if i try INSERT INTO APP.TEMP (ID, BOOL) VALUES (3, '0')
the response is Columns of type 'CHAR () FOR BIT DATA' cannot hold values of type 'CHAR'.
i thought to overpass is by creating the table with SQL code (CREATE TABLE...
), and set that column simply as 'bit', but when i do so the response i get is Syntax error: Encountered "bit" at line 7, column 8.
so how can i have a boolean field in a Derby DB? or should i give up and simply use integer?
cheers, eRez
Upvotes: 2
Views: 5424
Reputation: 16359
Derby has an actual BOOLEAN datatype, if that's what you're looking for: http://db.apache.org/derby/docs/10.8/ref/rrefsqljBoolean.html
Upvotes: 3