now this is a triple post 'cause i got no aswers yet (database, new to java forums). i'm posting it here just in case someone has any suggestions. this is needed so i can create my custom table model and then display the values in a table so it remotely touches swing too ((:
this is a double post, but in database forum i got no answers so i'm trying my luck here
hey all!
my question is this. i get data from postgresql database. i get ResultSet and then operate on it. when i'm taking the ResultSet apart to rows and columns and also detecting column types then i use this switch (below). it works fine except for boolean values.
i get values like this
private Vector<Object> getRowData(ResultSet rs, ResultSetMetaData rsMetaData)throws SQLException{
Vector<Object> row = new Vector<Object>();
//
for(int count=1;count<=rsMetaData.getColumnCount();count++){
switch(rsMetaData.getColumnType(count)){
case Types.INTEGER:
case Types.SMALLINT:
case Types.BIGINT:
row.add(rs.getInt(count));
break;
case Types.VARCHAR:
case Types.CHAR:
row.add(rs.getString(count));
break;
case Types.DATE:
row.add(rs.getDate(count));
break;
case Types.BOOLEAN:
row.add(rs.getBoolean(count));
break;
case Types.DOUBLE:
case Types.FLOAT:
row.add(rs.getDouble(count));
break;
}
}
return row;
}
when i try get values like
varchar first name, varchar last name, boolean isEmployee
then i always get array out of bounds exception on the row because the boolean value does not get detected. when i put JOptionPane.showMessageDialog(null,"show value here"); in the switch above like this
Types.VARCHAR
JOptionPane.showMessageDialog(null,"i'm varchar");
break;
Types.DATE
JOptionPane.showMessageDialog(null,"i'm date");
break;
Types.BOOLEAN
JOptionPane.showMessageDialog(null,"i'm boolean");
break;
.
.
.
then the data gets detected except for BOOLEAN part of the switch above????
i have done this previously with mysql and it worked fine. the only difference between these two databases is that mysql records booleans as '1' or '0' and postgresql as 't' or 'f'.
is this the possible source of my problems?? and how can this be solved.
i have used postgresql.jar driver (generic) and also postgresql-8.2-505.jdbc3.jar driver with the same wrong result.
if anybody has had similar problem or has something to say about this at all, please, let me know!
thanks
v.v.