Announcement Announcement Module
Collapse
No announcement yet.
Parameter value wrapping breaking query Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Parameter value wrapping breaking query

    Hi folks... I'm using Spring JDBC to work on a MySQL database. At one point I have to create a table with the following query:

    Code:
    CREATE TABLE data_:owner (
      id CHAR(36) NOT NULL,
      name VARCHAR(255) NOT NULL,
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    As you can see, I'm trying to insert a value to create a dynamic table name. The code I'm using is:

    Code:
    NamedParameterJdbcTemplate template =
      new NamedParameterJdbcTemplate(new JdbcTemplate(dataSource));
    template.update(sql, new BeanPropertySqlParameterSource(inVO));
    Now... this isn't my first go-round' with Spring JDBC, and this code WORKS, so long as I hardcode the name of the table in the query... so I know the query is correct and so is the general code itself.

    However, what's happening is that when the value of the owner field is inserted into the query, it's being wrapped in quotes... that's normally a good thing, but here it breaks the query.

    Maybe I'm just missing the obvious, but how can I deal with this? I thought about just altering the query to accommodate the quotes, but I don't see how I could... and looking through the Spring docs, I don't see a way to maybe temporarily turn off quote wrapping? Any pointers would be appreciate.

    Thanks,
    Frank

    Frank W. Zammetti
    Author of "Practical Ext JS Projects with Gears" (coming soon)
    and "Practical Dojo Projects"
    and "Practical DWR 2 Projects"
    and "Practical JavaScript, DOM Scripting and Ajax Projects"
    and "Practical Ajax Projects with Java Technology"
    (For info: apress.com/book/search?searchterm=zammetti&act=search)
    All you could possibly want is here: zammetti.com
Working...
X