Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 890987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:49:14+00:00 2026-05-15T13:49:14+00:00

I have tables in Mysql 5 db with names prefixed with a dollar sign

  • 0

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", .., .. ));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:49:15+00:00Added an answer on May 15, 2026 at 1:49 pm

    Database information like table and column names/identifers are not meant to be parameterized. MySQL uses the backtick (`) for table and column names/identifiers. Your parameterized query is probably going in as:

     select symbol, open, high, low, close, vol, ev from "$AAPL"
    

    I’m not aware of any standard API for parameterizing/escaping identifiers like that. I’d recommend, if you can, just to have it in there statically. Since they’re the same columns partitioning the table might also be an option. Finally, if you still need it to be dynamic, you’ll have to escape the table name yourself, I’d recommend only pulling it in from a whitelist.

    You may want to take a look at the mysql documentation on how to escape identifiers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using mysql and php, I have two tables, I'm french so the table names
Using MySQL, I have three tables: projects : ID name 1 birthday party 2
I'm using PHP/MySql. If I have two tables (hypothetically) as follows: id name and
I have a simple MySQL query like: SELECT * FROM `content_category` CC , `content_item`
I have two mysql tables, one listing article names, the other listing the authors
I have multiple MySQL tables with names of the form Shard_0, Shard_1, Shard_2 ...
I have errors when i try to query my MySQL tables in lowercase :
I have two MySQL tables: attributes (attributeid, name) productsattributes (productid, attributeid, displayvalue) The required
I have 5 tables in my Mysql database with t1 with field name like
I have two tables in a MySql DB: items id (char) name (varchar) description

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.