aspose file tools*
The moose likes JDBC and the fly likes inserting null values in the backend using enterprise 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 » Databases » JDBC
Bookmark "inserting null values in the backend using enterprise beans" Watch "inserting null values in the backend using enterprise beans" New topic
Author

inserting null values in the backend using enterprise beans

savitha rao
Greenhorn

Joined: Jun 05, 2001
Posts: 6
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

Joined: Aug 06, 2001
Posts: 34
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


Dil se....,<BR>Dayanand<BR>0065-8839071(off)<BR>0065-7547034(Res0
krishnan sampath
Greenhorn

Joined: Aug 08, 2001
Posts: 3
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

Joined: Aug 27, 2002
Posts: 6
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inserting null values in the backend using enterprise beans