I have tables in Mysql 5 db with names prefixed with a dollar sign '$' ie tablename $MYTABLE
I am using Spring 3.0 JdbcTemplate to do my select query but couldn't get it to work.
ie
String tablename = "$AAPL";
private static final String STOCK_SELECT =
"select symbol, open, high, low, close, vol, ev from ?";
jdbcTemplate.query(STOCK_SELECT,
new Object[] { tablename },
new RowMapper() { .... } );
This will always throws InvalidSqlException, presumably because of the $ sign. If I just do a normal query with no param, ie.
private static final String STOCK_SELECT =
"select symbol, open, high, low, close, vol, ev from $AAPL";
Then everything works.
How can I escape the $ sign using jdbcTemplate?
-- Edit, what I ended up doing --
Instead of passing the table name "$AAPL" to jdbcTemplate, I just create the SQL string manually, i.e.
jdbcTemplate.query( getStockSelect("$AAPL", .., .. ));