title: Unable to insert a row in Oracle with Java (JDBC) --> error ORA-00917: missing comma
body: <p>I have a problem during an insert in Oracle using Java and JDBC. The error obtained is:</p>
  
  <blockquote>
    <p>java.sql.SQLException: ORA-00917: missing comma</p>
  </blockquote>
  
  <p>The data for the insert is taken from a form like a string and is parsed to the appropiated data type and then is saved in an object called edicio. That's all OK. Then, my intention is make an insert in the DB using the data of this object.</p>
  
  <p>Here is the code of the DAO, where I'm making the insert:</p>
  
  <pre><code>public Edicio insertarCurs(Connection con, Edicio ed) throws SQLException {
      PreparedStatement stm = null;
      ResultSet rst = null;
  
      // Insert
      StringBuffer sql = new StringBuffer();
      sql.append("INSERT INTO curs (id, nom, idarea, area, programa, datainici)");
      sql.append(" VALUES (?, ?, ?, ?, ?, ?");
      logger.info("Building insert works fine.");
  
      try {
          stm = con.prepareStatement(sql.toString());
          // params
          stm.setLong(1, ed.getIdEdicio());
          stm.setString(2, ed.getNomEdicio());
          stm.setLong(3, ed.getIdArea());
          stm.setString(4, ed.getArea());
          stm.setString(5, ed.getPrograma());
          // Conversion from Java Date to SQL Date
          java.sql.Date sqlDate = new java.sql.Date(ed.getDataInici().getTime());
          logger.info("sqlDate before the insert is: "+ sqlDate); //0011-12-02
          stm.setDate(6, sqlDate);
  
                  // Data and results commented
          logger.info("Id edicio: "+ ed.getIdEdicio()); //6
          logger.info("Nom edicio: "+ ed.getNomEdicio()); //test
          logger.info("Id area: "+ ed.getIdArea()); //0
          logger.info("Nom area: "+ ed.getArea()); //test
          logger.info("Programa: "+ ed.getPrograma()); //test
          logger.info("Data inici: "+ sqlDate); //2011-06-06
  
          // We are going to execute the insert
          int numRows = stm.executeUpdate();
          // The program never reaches this point, fails doing the executeUpdate()
                  logger.info("Rows created: "+ numFiles);
                  ...
  </code></pre>
  
  <p>The variable types are:</p>
  
  <pre><code>idEdicio = long  
  nomEdicio = String  
  idArea = long  
  area = String  
  programa = String  
  dataInici = Date  
  </code></pre>
  
  <p>Can someone help me? Thank you in advance :)</p>