Back Forum Reply New

Weird Result with JDBCTemplace.query

Hello,

I'm using JDBCTemplate.query to make some query on a FoxPro 3.0 tables. The query works fines except for one value where I have no result ... can't figure out what's wrong or how to debug this ...

Here is the code :

Code:
public Symbol getSymbol(final String symbolValue) {
String query = quot;Select ascii, naam, font, Symbol, Unicode quot; +
quot; FROM AGIM_SYM quot; +
quot; WHERE Symbol = ?quot;;Symbol result = (Symbol)getJdbcTemplate().query(query, new Object[]{Integer.parseInt(symbolValue)},new ResultSetExtractor(){
public Object extractData(ResultSet rs) throws SQLException, DataAccessException {
Symbol s = null;
if(rs.next()){
final String unicodeValue = rs.getString(5).trim();
final SymbolEnum symbolEnum = SymbolEnum.getSymbolEnumFromCode(Integer.toString(rs.getInt(3)));

s = new Symbol(){
public SymbolEnum getSymbolType() { return symbolEnum;}
public String getUnicodeValue(){ return unicodeValue;}
};
}else{
System.out.println(quot;SymBol not found quot; + symbolValue);
}

return s;
}
});

return result;
}
and here is the Bean for the datasource :

Code: lt;bean id=quot;agimFoxProDSquot; class=quot;org..jdbc.datasource.DriverManagerDataSourcequot;gt;       lt;property name=quot;driverClassNamequot;gt;lt;valuegt;sun.jdbc.odbc.JdbcOdbcDriverlt;/valuegt;       lt;/propertygt;       lt;property name=quot;uclquot;gt;         lt;valuegt;jdbcdbc:AGIM-FOXPROlt;/valuegt;       lt;/propertygt;       lt;property name=quot;usernamequot;gt;lt;value/gt;       lt;/propertygt;       lt;property name=quot;passwordquot;gt;lt;value/gt;      lt;/propertygt;   lt;/beangt;
As said, everything works fine except when the value quot;200quot; is given. The record do exist in the database (tried to recompile the table, delete / reInsert the record) and executing the query in an external tool do work. When modifying the where clause of the query, if I use where symbol = 200 with the hardcoded parameter, I still get no result. I also tried with something like where symbol gt; 199 and symbol lt; 201 and still didn't works. When using where symbol gt; 199 order by Symbol I do get the correct record. When making a select * from AGIM_SYM and outputing the list of record, the problem record is in the list.

Does someone have an idea of what is the problem ? I mulst admit I'm really stuck here

Is quot;symbolquot; numeric or a string type? If it is the latter, maybe there are leading/trailing blanks in the database which will be trimmed by your external viewer?

Just an idea,
Andreas

Symbol is numeric in the database, I'd have been to easy otherwise

I have recreated the record in question so to be sure that it wasn't due to mistipping or other things like that.
¥
Back Forum Reply New