Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inserting null values in the backend using enterprise beans

 
savitha rao
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
DAYANAND BURAMSHETTY
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
krishnan sampath
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Vikranth Gujjar.
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic