title: java enum and postgresql enum
body: <pre><code>CREATE TABLE customers
  (
    first_name character varying(15),
    second_name character varying(20),
    login character varying(15) NOT NULL,
    password character varying(15),
    email character varying(40),
    gender gender,
    register_date date,
    date_of_birth date,
    address character varying(40),
    address_number integer,
    town character varying(20),
    CONSTRAINT login PRIMARY KEY (login)
  )
  </code></pre>
  
  <p>I have this table and I created an enum of gender such as:</p>
  
  <pre><code>CREATE TYPE gender AS ENUM ( 'F', 'M',);
  </code></pre>
  
  <p>I am trying to insert into customers data from eclipse java with PreparedStatement
  but there is an error such as ERROR: column "gender" is of type gender but expression is of type character varying
    Hint: You will need to rewrite or cast the expression.</p>
  
  <p>My Java code looks like: </p>
  
  <pre><code>PreparedStatement pre_state;
  
  public enum gendertype {
      F,
      M;
  }
  
  pre_state = conn.prepareStatement("INSERT INTO"
              + " customers VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  pre_state.set(6, gendertype.F.toString());
  </code></pre>