Weird error with query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WilHob
    New Member
    • May 2007
    • 5

    Weird error with query

    Hello:
    I executed many times queries in various DBMS but got such error when I started
    to work with MySQL. I run simple query from Java in NetBeans:
    ...
    string s1;
    s1="abc";
    ...
    stmt.executeUpd ate("INSERT INTO Table(F1) VALUES(s1)");
    ...
    I got this error message:

    SQLException: Unknown column 's1' in 'field list'
    ...
    What is wrong???
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    A few things. First off read up on the specification for the INSERT statement.

    mysql INSERT

    Secondly, your string s1 is not being interpolated. You either need to use placeholders or manually specify that the string should be interpolated.

    - Miller

    Comment

    • WilHob
      New Member
      • May 2007
      • 5

      #3
      Originally posted by miller
      A few things. First off read up on the specification for the INSERT statement.

      mysql INSERT

      Secondly, your string s1 is not being interpolated. You either need to use placeholders or manually specify that the string should be interpolated.

      - Miller


      Hello, Miller:
      Thanks for reply.
      I know in general about Interpolate and placeholder but never used it in practice.
      I know sintax INSERT operator and used it many times with DBMSs
      (Oracle, Foxpro and others) and never had any problems. If it really necessarily to interpolate string, how it practically to do?
      Thanks

      Comment

      Working...