BIT, VARBIT
BIT, VARBIT#
This section offers information on managing BIT,VARBIT type data in JDBC application and related considerations.
How to Use#
BIT, VARBIT type data can be manipulated by using Java BitSet class in ALTIBASE HDB JDBC application.
When using IN parameter of PreparedStatement, either the Types.BIT type should be specified or the value can be specified with BitSet or a character string when not specifying the type.
Notes#
In order to create BIT,VARBIT value with a bit ending with '0', use AltibaseBitSet which can be set with bit values of specified length or character string values. The Java BitSet is implemented to remember which bits have been set() because a BIT value of 0 length cannot be created.
Example#
The following is an example code for inserting data in BIT, VARBIT type columns in JDBC application.
...
BitSet sBitSet1 = new BitSet();
sBitSet1.set(1);
BitSet sBitSet2 = new AltibaseBitSet( 5 );
sBitSet1.set(2);
PreparedStatement sPstmt = sConn.prepareStatement("INSERT INTO TEST_TABLE VALUES (?)");
sPstmt.setObject(1, sBitSet1, Types.BIT);
sPstmt.executeUpdate();
sPstmt.setObject(1, sBitSet2);
sPstmt.executeUpdate();
sPstmt.setObject(1, "0110100", Types.BIT);
sPstmt.executeUpdate();
...