aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Storing date in DB using Entity Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Storing date in DB using Entity Beans" Watch "Storing date in DB using Entity Beans" New topic
Author

Storing date in DB using Entity Beans

Diwakar
Greenhorn

Joined: May 23, 2005
Posts: 9
Hi,
Iam struck with the following, please help me.
After accepting date from a JSP page in the form of String, I want it to be stored into the data-base using EntityBean. The corresponding fields in Oracle are DATE (sql data-type) and java.sql.Date in my CMP field.
Now the problem was do I convert the accepted date to java.sql.Date, which I did by using java.sql.Date.parse("accepted date from JSP"); But Iam getting exception when I try to insert it into the Data-base.
What is the solution to this problem?? Is there any other solution to "insert a into a Data-base using an entity-bean" ??
Marco Barenkamp
Ranch Hand

Joined: Aug 27, 2001
Posts: 94
Hi,

when Entity Beans deal with Date or Time values, they must be converted into
long values.
Additionally, finder or select methods cannot work with date objects either.
You have to use the appropriate long value instead.


Marco Barenkamp<br />_ _ _ _ _ ________________________ _ _ _ _ _ <br />L M I N T E R N E T S E R V I C E S AG<br /> <br />Head of Software Development<br /> <br /> <br />BEA Certified Enterprise Developer<br />Sun Certified Programmer for the Java2 Platform<br />Sun Certified Web Component Developer for the Java2 Platform<br />Sun Certified Developer for the Java 2 Platform <br />Sun Certified Business Component Developer for the Java 2 Platform <br />Sun Certified Enterprise Architect for the Java 2 Platform Enterprise Edition<br /> <br />LMIS AG
 
 
subject: Storing date in DB using Entity Beans