title: Why does my code not fill a table in database?
body: <p>The following code works:</p>
  <pre><code>import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.SQLException;
  import java.sql.Statement;
  
  public  class ItemGroupInputFromConsole extends Parser{
  
  public ItemGroupInputFromConsole() {
  
  }
  @Override
  public void visit(ItemGroup itemGroup) throws SQLException{
      System.out.println(&quot;ItemGroup String id, String group_name&quot;);
      super.readRawInput();
      String[] rawinput = super.getRawInput();
      itemGroup.setId(rawinput[0]);
      itemGroup.setGroup_name(rawinput[1]);
      String SQLinsert = &quot;INSERT INTO \&quot;Item_Group\&quot;(id,group_name) &quot;
              + &quot;VALUES(?,?)&quot;;
  
  
  
      PreparedStatement pstmt = super.connection.prepareStatement(SQLinsert, Statement.RETURN_GENERATED_KEYS);
  
      pstmt.setString(1, itemGroup.getId());
      pstmt.setString(2, itemGroup.getGroup_name());
  
      pstmt.executeUpdate();
  }
  </code></pre>
  <p>When I try almost similar code it produces a runtime error:</p>
  <pre><code>import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.SQLException;
  import java.sql.Statement;
  
  public class UserInputFromConsole extends Parser {
  
  public UserInputFromConsole(){
  
  }
  @Override
  public void visit(User user) throws SQLException {
      System.out.println(&quot;User String id, String name, int age, String adress, int account,    String bad_behaviour&quot;);
      super.readRawInput();
      String[] rawinput = super.getRawInput();
      user.setId(rawinput[0]);
      user.setName(rawinput[1]);
      user.setAge(rawinput[2]);
      user.setAdress(rawinput[3]);
      user.setAccount(rawinput[4]);
      user.setBad_behaviour(rawinput[5]);
      String SQLinsert = &quot;INSERT INTO user(id,name,age,adress,account,bad_bahaviour) &quot;
              + &quot;VALUES(?,?,?,?,?,?)&quot;;
  
  
      PreparedStatement pstmt = super.connection.prepareStatement(SQLinsert, Statement.RETURN_GENERATED_KEYS);
  
      pstmt.setString(1, user.getId());
      pstmt.setString(2, user.getName());
      pstmt.setString(3, user.getAge());
      pstmt.setString(4, user.getAdress());
      pstmt.setString(5, user.getAccount());
      pstmt.setString(6, user.getBad_behaviour());
  
      pstmt.executeUpdate();
  }}
  </code></pre>
  <p>The error is on the line pstmt.executeUpdate(); in the second code. The first code works, the second produces an error.
  Where do I have to debug, in order to find this error?
  Maybe in the database?</p>
  <p>Why is this happening?
  The error is syntax error in user but the first one is on line with
  pstmt.executeUpdate().</p>
  <p>Error I get:
  <a href="https://i.stack.imgur.com/UMkxu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UMkxu.png" alt="enter image description here" /></a></p>