wood burning stoves 2.0*
The moose likes JDBC and the fly likes getBoolean and boolean values in CSV file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "getBoolean and boolean values in CSV file" Watch "getBoolean and boolean values in CSV file" New topic

getBoolean and boolean values in CSV file

Mark Ashworth

Joined: Nov 02, 2000
Posts: 11
Good Day,
I am trying to find out which character equates to a boolean true value. I have found out that `K` `F` `0` equates to false but for some reason `T` `1` `Y` or `S` do not equate to true. If also tried `TRUE` `true` `True` `-1` and the rest of the alphabet.
I am using the ODBC driver for text files which uses the Microsoft CSV/Excel driver.
Mark Ashworth
Lee Wallen

Joined: Jul 14, 2001
Posts: 10
1 appears to work. I have the fourth field defined as a byte.
The text file contents:
The sample code:
import java.sql.*;
public class TextReader
public static void main( String [] args ) {
Connection c = null;
Statement stmnt = null;
try {
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection( "jdbcdbc:text_test", "", "" );
stmnt = c.createStatement();
String query = "select * from [test.txt];";
ResultSet rs = stmnt.executeQuery( query );
while( rs.next() )
System.out.print( rs.getString( "Field1" ) + "\t");
System.out.print( rs.getString( "Field2" ) + "\t");
System.out.print( rs.getString( "Field3" ) + "\t");
System.out.println( rs.getBoolean( "Field4" ) );
} catch( Exception e ) {
System.err.println( e );
} finally {
try {
} catch( Exception e ) {
System.err.println( e );
} // end of try catch
} // end of main
Output of code:
Field1 Field2 Field3 true
this is a false
this2 is2 a2 false
this3 is3 a3 true

[This message has been edited by Lee Wallen (edited July 15, 2001).]
I agree. Here's the link: http://aspose.com/file-tools
subject: getBoolean and boolean values in CSV file