aspose file tools*
The moose likes JDBC and the fly likes Double, Float Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Double, Float" Watch "Double, Float" New topic
Author

Double, Float

Manuel Paco
Ranch Hand

Joined: Sep 23, 2001
Posts: 58
I am using MSAccess database 2002 and I have a column of type double but my code in Java does not seem to recognize Types.FLOAT and DOUBLE from database when I try to read it into vector.
Any idea what I am doing wrong?
Types.LONGVARCHAR, VARCHAR, INTEGER work fine.
Thank you.
for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
switch( rsmd.getColumnType( i ) ) {
case Types.LONGVARCHAR:
currentRow.addElement( "" + rs.getString( i ) );
break;
caseTypes.VARCHAR:
currentRow.addElement( "" + rs.getString( i ) );
break;
case Types.INTEGER:
currentRow.addElement(new Long( rs.getLong(i) ) );
break;
case Types.FLOAT:
currentRow.addElement(new Float(rs.getFloat(i)));
break;
caseTypes.DOUBLE:
currentRow.addElement(new Double(rs.getDoubl(i)));
break;
}
Michael Zalewski
Ranch Hand

Joined: Apr 23, 2002
Posts: 168
Are you executing the branch of the case statement for Types.FLOAT and Types.DOUBLE? I bet its because the driver translated the column type to something else (Types.NUMBER?)
Use ResultSetMetaData to see what the actual type of the column is.
Manuel Paco
Ranch Hand

Joined: Sep 23, 2001
Posts: 58
Thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Double, Float
 
Similar Threads
Create JTable custom editor to validate againts string data type
Get Column Type
mySQL INTEGER == LONG in Java and ....???
JTable AbstractTableModel Edit Date Problem
JTable date edit problem