Results 1 to 3 of 3
  1. #1
    vector_ever is offline Senior Member
    Join Date
    Jul 2013
    Rep Power

    Default Insert Enum in Database

    Assume the following enumeration:
    Java Code:
    public enum FederalState {BW, BY, BE, BB, BR, HH, HE, MV, NI, NR, RP, SL, SN, ST, SH, TH}
    Java Code:
    public class Location {
    	private FederalState state;
    	private String ort;
    	private String PLZ;
    	private String strasse;
    	private String country;
    //setters and getters
    PreparedStatement ps = null;
    ps = con.prepareStatement(query);
    	           Iterator<Location> it = set.iterator();
    	           while (it.hasNext()){
    	           Location obj =;
    	           ps.setString(1, obj.getState()); //error State is type enum not String but there is no setEnum
    	           ps.setString(2, obj.getOrt());	           
    	           ps.setString(3, obj.getPLZ());
    	           ps.setString(4, obj.getStrasse());
    because state is enumeration type (not String or another type) so how to deal with it to get the write instruction with prepareStatement

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Rep Power

    Default Re: Insert Enum in Database

    Cross posted at setter of Type Enum

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Rep Power

    Default Re: Insert Enum in Database

    toString() the enum value?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Create registration form | insert into database | call the database
    By FamilyGuy in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 04-23-2012, 12:08 PM
  2. insert vector to database
    By jperson in forum JDBC
    Replies: 4
    Last Post: 01-20-2011, 03:42 AM
  3. how to insert data in database
    By Vinay Bhatia in forum JDBC
    Replies: 6
    Last Post: 11-03-2010, 05:06 PM
  4. why i can't insert data to database
    By khaa_khay in forum Web Frameworks
    Replies: 0
    Last Post: 05-26-2010, 06:37 AM
  5. Replies: 3
    Last Post: 02-28-2009, 10:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts