• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inserting null values in the backend using enterprise beans

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to insert null values to any datatype in the backend using enterprise beans. EJB1.0. Can anyone let me know whether it is possible to do like that thank you in advance
regards
savitha
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
U can insert null values........
public ExPK insert(ExTB rcd) {

Connection con=null;
PreparedStatement ps=null;
String strQry=null;
try {
con = getConnection();
strQry = "INSERT INTO SEA_FILE (USERNAME,PASSWROD,MAILID,USERID..... "+
" VALUES (?, ?, ?,?.... )";
ps = dbConnection.prepareStatement(strQry);
ps.setString(1, rcd.getUserName());
ps.setString(2, rcd.getPassword());
if(rcd.getEmailId()==null){
// MAILID IS VARCHAR TYPE IN USER TABLE
// SET NULL VALUE FOR MAILID
ps.setNull(3, java.sql.Types.VARCHAR);
}else{
ps.setString(3,rcd.getEmailId());
}
if ( rcd.getUserId()!=0 ){
//USERID IS INTEGER TYPE IN USER TABLE
// SET NULL(0) VALUE FOR USERID
ps.setNull(4, java.sql.Types.INTEGER);
}else{
ps.setInt(4, rcd.getUserId());
}

}//EOF INSERT
If I'm wrong .. Correct me
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can insert null values as given by DAYANAND BURAMSHETTY
but what is the use of inserting a null value..
In general, EJB recommends entity beans(both CMP and BMP)to insert a primary key value using ejbCreate and update it in ejbStore.
We can also use stateless beans for executing DML statements and complex transactions.
So please tell me the scenario that leads you to have nulls inserted. It will be usefull for me to implement it in my ejbFramework.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering what would happen if I try to insert Integet.NaN into data base.
eg,

userDTO.setAge(Integer.NaN);
pstmt.setInt(1,userDTO.getAge):
Please let me know if this would work..
Vikranth
reply
    Bookmark Topic Watch Topic
  • New Topic