• Post Reply Bookmark Topic Watch Topic
  • New Topic

SQL & Java Data Mapping using EJB

 
gautam anand
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created an EJB corresponding to one of the auidt tables and the problem I am having is that when using the getter methods of the bean to get the values of the tables columns I get null pointer exceptions because some of the columns have null values. Is there a way to handle this. Also the other problem I have is that we have a column in the table with Oracle data type Date, format: mm/dd/yy hh:mm:ss, which on coversion to the java.sql.Date type returns only the Date part of the database value. Is there a way to extract the complete data format value?.

Your help would be greatly appreciated.

Thanks
Gautam
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most obvious way to avoid NPEs in any Java program is to check if a reference is null before calling methods on it.

Layne
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35740
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gautam,
java.sql.Date stores precision to the nearest date. java.sql.TimeStamp stores the time and date values. So if you map to TimeStamp instead, you will get the full value as stored in Oracle.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!