PostgreSQL Hint: You will need to rewrite or cast the expression. column "state" is of type status but expression is of type character varying : <p>I am trying to create a SQL statement using java. The problem is I am using</p>

<pre><code> stmt.setString(9, ev.getState().status());
</code></pre>

<p>for a variable I am trying to insert into a SQL column of type status </p>

<pre><code> CREATE TYPE STATUS AS ENUM ('APPROVED', 'CLOSED','STARTED', 'WAITING');
</code></pre>

<p>It is throwing me an exception of </p>

<pre><code>column "state" is of type status but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
</code></pre>

<p>Did I make a mistake or do I actually need to cast the value in sql? If yes, how does one cast in this situation?</p>

<p>Full Statement:</p>

<pre><code>     PreparedStatement stmt = conn.prepareStatement("INSERT INTO Event (EventNum, EventName, startHour, endHour, startMin, endMin, startDate, endDate, State, depName) VALUES (?, ?, ?, ?, ?, ?, ?::date, ?::date, ?, ?)");




     stmt.setInt(1, ev.getEventNum());
     stmt.setString(2, ev.getName());
     stmt.setInt(3, ev.getStartHour());
     stmt.setInt(4, ev.getEndHour());
     stmt.setInt(5, ev.getStartMinute());
     stmt.setInt(6, ev.getEndMinute());
     stmt.setString(7, ev.getStartYear() + "-" + ev.getStartMonth() + "-" + ev.getStartDate());
     stmt.setString(8, ev.getEndYear() + "-" + ev.getEndMonth() + "-" + ev.getEndDate());
     stmt.setString(9, ev.getState().status());
     stmt.setString(10, ev.getDepartment());



     stmt.executeUpdate();
</code></pre>
