freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: ResultSet.getBoolean() against a BIT columntype always returns fa lse
- From: Stefan Bodewig <bodewig AT bost.de>
- To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
- Subject: Re: ResultSet.getBoolean() against a BIT columntype always returns fa lse
- Date: 14 Apr 2000 16:22:50 +0200
>>>>> "MM" == Maraya Michael <maraya-michael AT dol.gov> writes:
MM> Hello, ResultSet.getBoolean() seems to return false when the
MM> column passed is a BIT ( 0 == false, 1 == true ) regardless of
MM> what the content of the column is.
Sorry, I cannot confirm this. The appended testcase - needs
Common.java from the unittests directory - works for me (SQL Server
7.0) and checks exactly the implied semantics (0==false, 1==true).
Stefan
import java.sql.*;
import java.io.*;
/**
* test setting and getting long values.
*
*/
public class bittest
{
static public void main(String args[])
throws SQLException, java.lang.ClassNotFoundException, IOException
{
boolean passed = true;
System.out.println("Starting test bittest- test setting and getting
BITs");
// open the database
int count = 0;
Connection cx = Common.getConnection();
Statement stmt = cx.createStatement();
try
{
stmt.executeUpdate("drop table bittest");
}
catch (SQLWarning e)
{
String okayError = "Cannot drop the table";
if (! (e.getMessage().startsWith(okayError)))
{
throw e;
}
}
count = stmt.executeUpdate("create table bittest (t1 BIT NOT NULL)");
System.out.println("Creating table affected " + count + " rows");
count = stmt.executeUpdate("insert into bittest VALUES (0)");
System.out.println("Added " + count + " rows");
ResultSet rs1 = stmt.executeQuery("select t1 FROM bittest");
rs1.next();
if (rs1.getBoolean("t1") != false) {
System.out.println("Expected false");
passed = false;
}
rs1.close();
count = stmt.executeUpdate("update bittest set t1 = 1");
System.out.println("Changed " + count + " rows");
rs1 = stmt.executeQuery("select t1 FROM bittest");
rs1.next();
if (rs1.getBoolean("t1") != true) {
System.out.println("Expected true");
passed = false;
}
rs1.close();
stmt.close();
cx.close();
System.out.println("\n" + (passed ? "Passed" : "Failed")
+ " bittest.\n");
System.exit(passed ? 0 : 1);
}
}
-
ResultSet.getBoolean() against a BIT columntype always returns fa lse,
Maraya Michael, 04/13/2000
- <Possible follow-up(s)>
- Re: ResultSet.getBoolean() against a BIT columntype always returns fa lse, Stefan Bodewig, 04/14/2000
Archive powered by MHonArc 2.6.24.