Hi: I'm having problems geting the columnType DATE, this is the code I used for my program, rsmd is ResulSetMetaDeta switch( rsmd.getColumnType( i ) ) { case Types.INTEGER: currentVector.addElement( local + String.valueOf(rs.getInt(i))); break; case Types.DECIMAL: currentVector.addElement( local + String.valueOf(rs.getInt(i))); break; case Types.FLOAT: currentVector.addElement( local + two.format(rs.getFloat(i))); break; case Types.DOUBLE: currentVector.addElement( local + two.format(rs.getDouble(i))); break; case Types.NUMERIC: currentVector.addElement( local + two.format(rs.getDouble(i))); break; case Types.CHAR: currentVector.addElement( local + rs.getString(i)); break; case Types.VARCHAR: currentVector.addElement( local + rs.getString(i)); break; case Types.LONGVARCHAR: currentVector.addElement( local + rs.getString(i)); break; case Types.DATE: StringTokenizer tokens = new StringTokenizer( rs.getDate ( i ).toString(), "-" ); String year = "/" + tokens.nextToken(); currentVector.addElement( local + tokens.nextToken() + "/" + tokens.nextToken() + year ); break; case Types.TIME: currentVector.addElement( local + rs.getTime( i ) ); break; default: System.out.println( "The type was:: " + rsmd.getColumnTypeName( i ) + rsmd.getColumnName( i ) ); currentVector.addElement( local + defaultString ); } thanks yoel stern ------------------ Sun Certified Programmer for JAVA 2 Platform
jenkinstechnology llc
Greenhorn
Joined: Aug 18, 2001
Posts: 7
posted
0
what do you have defined in the database as the datatype? for example, on Microsoft SQL Server, a datetime maps to Types.TIMESTAMP, not Types.DATE like you'd think. not sure if this helps, but I saw you didn't have Types.TIMESTAMP in your case statement. paul
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
Thank You Paul: You did help me I'm using MS Access because you gave me an idea that in some databases there is diffrent kinds of Type DATE. I dont know about TIMESTAMP (since I'm using Access) but I see that I didn't use one Type DATETIME now its working exclent I got my column type thru method getColumnTypeName(). I wish you luck Yoel
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.