InstantDB Project
About InstantDB
Project Mail Lists
Short History
Reporting Bugs
Screen Shots
3rd Party Examples
FAQs

Software
Downloads
Documentation
CVS Repositories
Roadmap
License

About Enhydra.org
Who We Are
News, Articles & Events
Getting Involved
Contact Us

Community
Demos
Contributions
Resources
Case Studies
On The Edge! -NEW-
Commercial Vendors


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

InstantDB: Boolean blues . . .


I'm having problems with the boolean type. I want
to work with boolean's, but it seems like
PreparedStatement.setBoolean is failing . . .

import java.sql.*;

public class BooleanTest {

    public static void main( String[] args )
    {

        Connection con  = null;
        Statement  stmt = null;
        ResultSet  rs   = null;

        try {

            // Load the driver, get a connection, create statement, run
query, and print.

            Class.forName("org.enhydra.instantdb.jdbc.idbDriver");
            con = DriverManager.getConnection(
"jdbc:idb:/tmp/idbtest/discRack.prp" );

            PreparedStatement ps = con.prepareStatement( "SELECT * FROM
booltest WHERE tall = ?" );

            ps.setBoolean( 1, true);
            rs = ps.executeQuery();

            while( rs.next()) {
                System.out.println( rs.getString( "name" ) + "\t" +
rs.getBoolean( "tall" ) );
            }

        }
        catch(ClassNotFoundException e) {
            System.err.println( "Couldn't load the driver: " +
e.getMessage());
        }
        catch(SQLException e) {
            System.err.println( "SQLException caught: " + e.getMessage());
        }
    }
}

>From the table:

d org.enhydra.instantdb.jdbc.idbDriver;
o jdbc:idb=/tmp/idbtest/discRack.prp;
e drop table booltest;
e create table booltest(
    oid int primary key,
    name varchar(30),
    tall boolean );
e insert into booltest values ( 1, "Otis", "false" );
e insert into booltest values ( 2, "Ollie", "true" );
q  select booltest.* from booltest;
q  select booltest.* from booltest WHERE tall="false";
q  select booltest.* from booltest WHERE tall="true";
c close;

Where the error is  . . .

cicero (611) java BooleanTest
Enhydra InstantDB - Version 3.14
The Initial Developer of the Original Code is Lutris Technologies Inc.
Portions created by Lutris are Copyright (C) 1997-2000 Lutris Technologies,
Inc.
All Rights Reserved.
main SELECT * FROM booltest WHERE tall = true
main java.lang.ClassCastException: java.lang.Boolean
SQLException caught: java.lang.Boolean

Any hints ?

Peter


``````````````````````
Peter Darrah
Staff Engineer
Lutris Technologies       http://www.lutris.com
Sponsors of Enhydra    http://www.enhydra.org
(831) 460-7359

-----------------------------------------------------------------------------
To unsubscribe from this mailing list, send email to majordomo@enhydra.org
with the text "unsubscribe instantdb" in the body of the email.
If you have other questions regarding this mailing list, send email to
the list admin at owner-instantdb@enhydra.org.