I display the date in JSF using pattern="dd-MMM-yyyy"
.
When I try to insert / update date values ββin my oracle DB, I get
java.sql.SQLException: Invalid column type
because my date format before inserting or updating 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 way to do 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 {
The prepared part of the code 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 < values.length; i++) { preparedStatement.setObject(i + 1, values[i]); logger.info("sql "+Arrays.asList(values)); } }
source share