title: Date Format Error java.sql.SQLException: Invalid column type
body: <p>I am displaying date in JSF using <code>pattern="dd-MMM-yyyy"</code>.</p>
  
  <p>When I am trying to insert/update date values into my oracle DB, I am getting </p>
  
  <pre><code>java.sql.SQLException: Invalid column type
  </code></pre>
  
  <p>because my date format before insert or update is in this format</p>
  
  <pre><code>Wed Feb 09 00:00:00 AST 2011
  </code></pre>
  
  <p>How can I correctly insert or update my date values to Oracle Db and what is the best approach for doing this?</p>
  
  <p><em>Update 1</em></p>
  
  <p>My db insert code.</p>
  
  <pre><code>private void editSchedule(Schedule schedule)
          Object[] values = { schedule.getStartDate(),
                  schedule.getVacationId() };             
          Connection connection = null;       
          PreparedStatement preparedStatement = null; 
          try {                           
              connection = datacon.getConnection();               
              preparedStatement = prepareStatement(connection, SQL_EDIT, values);         
              preparedStatement.executeUpdate();          
  
          } catch (Exception e) {
              logger.info("errro "+e.getMessage());
              e.printStackTrace();
          } finally {
              // TODO: handle exception
              close(connection, preparedStatement);
          }
  
      }
  </code></pre>
  
  <p>PreparedStaement code part</p>
  
  <pre><code>public static PreparedStatement prepareStatement
          (Connection connection, String sql, Object... values)
              throws SQLException
      {
          PreparedStatement preparedStatement = connection.prepareStatement(sql
              );
          setValues(preparedStatement, values);
          return preparedStatement;
      }
  
      public static void setValues(PreparedStatement preparedStatement, Object... values)
          throws SQLException
      {
          for (int i = 0; i &lt; values.length; i++) {
              preparedStatement.setObject(i + 1, values[i]);
              logger.info("sql  "+Arrays.asList(values));
          }
      }
  </code></pre>