• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getBoolean and boolean values in CSV file

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Regards,
Mark Ashworth
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1 appears to work. I have the fourth field defined as a byte.
The text file contents:
<pre>
Field1,Field2,Field3,1
this,is,a,0
this2,is2,a2,0
this3,is3,a3,1
</pre>
The sample code:
<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( "jdbc:odbc: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");
</code>
<em>
System.out.println( rs.getBoolean( "Field4" ) );
</em>
<code>
}
rs.close();
} catch( Exception e ) {
System.err.println( e );
} finally {
try {
stmnt.close();
c.close();
} catch( Exception e ) {
System.err.println( e );
}
} // end of try catch
} // end of main
}
</code>
Output of code:
<pre>
Field1 Field2 Field3 true
this is a false
this2 is2 a2 false
this3 is3 a3 true
</pre>

[This message has been edited by Lee Wallen (edited July 15, 2001).]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic