title: java mysql database insert using prepared statement
body: <p>I've seen a lot of questions regarding this topic but none seems to be the correct solution. I've trying to insert a new row into my database using preparedstatements but I'm getting an error:</p>
  
  <pre><code>com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1, 2, 3, 4, 5, 6, 7, 8, 9, guess, answer, value) VALUES (17, 187, 224, 276, 19, ' at line 1
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>String query = "INSERT INTO block (1, 2, 3, 4, 5, 6, 7, 8, 9, guess, answer, value)" + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
          PreparedStatement pst = con.prepareStatement(query);
          pst.setInt(1, array[0]);
          pst.setInt(2, array[1]);
          pst.setInt(3, array[2]);
          pst.setInt(4, array[3]);
          pst.setInt(5, array[4]);
          pst.setInt(6, array[5]);
          pst.setInt(7, array[6]);
          pst.setInt(8, array[7]);
          pst.setInt(9, array[8]);
          pst.setString(10, String.valueOf(letter[guess]));
          pst.setString(11, String.valueOf(answer));
          pst.setInt(12, value);
  
          pst.executeUpdate();
  </code></pre>
  
  <p>This is my db:
  <a href="https://i.stack.imgur.com/F5IZl.png" rel="nofollow noreferrer">sql</a></p>
  
  <p>I feel like I'm missing something really simple. . .</p>
  
  <p>Any help would be highly appreciated!
  Thank you!</p>