If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 + enumerated data types in Java 5

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-23-07, 03:09
ASHOKJOSE ASHOKJOSE is offline
Registered User
 
Join Date: Jun 2007
Posts: 8
Question DB2 + enumerated data types in Java 5

Hello there,

I need an help relating to Java5 enumerated data type and DB2.

Suppose I have something like this in my Java Program

enum Season {WINTER, SPRING, SUMMER, FALL};
Season season=Season.WINTER;
stmt.execute("create table enumtable(id int)");
PreparedStatement pstmt=con.prepareStatement("insert into tab1 values (?)");
System.out.println("OK");
pstmt.setObject(1,season);
System.out.println("Does not come here ");
pstmt.executeUpdate();
con.commit();

The output is this

Invalid data conversion: Parameter instance WINTER is invalid for the requested conversion.

Could someone let me know how do I insert the enumerated data type Object into DB2.
What should the column type be? Is this feature supported ?

Is it not possible to do this, just like the Clob or Blob objects which can be inserted into a Column with Clob or Blob Column types ?

Ashok Jose
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On