title: how to insert into mysql database with java
body: <p>i want to insert inputs i take from user into mysql database the connection is right but the insertion gives me error </p>
  
  <blockquote>
    <p>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 ''u_fname',
    'u_lname', 'u_uname', 'u_pass', 'u_age', 'u_adderess') values('20','o'
    at line 1</p>
  </blockquote>
  
  <p>My code is:</p>
  
  <pre><code>public void adduser(User s) {
     try {
          sql = "insert into users ('u_fname', 'u_lname', 'u_uname', 'u_pass', 'u_age', 'u_adderess')"
                  + "values('" + s.getFirstname() + "','" + s.getLastname()
                  + "','" + s.getUsername() + "','" + s.getPassword() + "','" + s.getAge() + "','" + s.getAdderss() + "')";
          stmt = conn.createStatement();
          int i = stmt.executeUpdate(sql);
          if (i &gt; 0) {
              System.out.println("ROW INSERTED");
          } else {
              System.out.println("ROW NOT INSERTED");
          }
      } catch (Exception e) {
          System.out.println(e);
      }
  
  }
  </code></pre>