I am displaying date in JSF using pattern="dd-MMM-yyyy"
.
When I am trying to insert/update date values into my oracle DB, I am getting
java.sql.SQLException: Invalid column type
because my date format before insert or update is in this format
Wed Feb 09 00:00:00 AST 2011
How can I correctly insert or update my date values to Oracle Db and what is the best approach for doing this?
Update 1
My db insert 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);
}
}
PreparedStaement code part
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 < values.length; i++) {
preparedStatement.setObject(i + 1, values[i]);
logger.info("sql "+Arrays.asList(values));
}
}