LoginPassward class:package user.login;
public class LoginPassword{
  public LoginPassword(){}
  static char[] digits = {
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
    'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
    'U', 'V', 'W', 'X', 'Y', 'Z' };
  static public String genPassword(){
    int temp;
    String password = "";
    for( int i=0; i<8; i++ ){
      temp = ( new Double( Math.random() *  997 ) )
        .intValue() % 36;
      password += String.valueOf( digits[ temp ] );
    }
    return  password;
  }
}

解决方案 »

  1.   

    javabean:package user.javabean ;
    import user.ejb.*;
    import java.util.*;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.rmi.PortableRemoteObject;
    import javax.ejb.*;
    import java.sql.*;public class UserData{  private String id=null;
      private String password=null;
      private String name=null;
      private String age;
      private String telephone;
      private String address;
      UserHome userhome=null;  public UserData() throws SQLException{
        try{
          Properties h = new Properties();
          h.put(Context.INITIAL_CONTEXT_FACTORY,
            "weblogic.jndi.WLInitialContextFactory");
          h.put(Context.PROVIDER_URL, "t3://localhost:7001");
          Context ctx = new InitialContext(h);
          Object homeObject = ctx.lookup("userRemote");
          userhome=(UserHome)PortableRemoteObject.narrow(homeObject,UserHome.class);
        }catch(Exception ex){
          ex.printStackTrace();
          throw new SQLException(ex.toString());
        }
      }  public void updateUser() throws SQLException{
        try{
          User user=userhome.findByPrimaryKey(id);
        }catch(Exception ex){
          throw new
            SQLException("載蜊囮啖!");
        }
      }  public void insertUser() throws SQLException{
        try{
          User user=userhome.create(id, name, age, telephone, address);
          this.password=user.getPassword();
        }catch(DuplicateKeyException dupkeyex){
          throw new
            SQLException("id : "+id+"眒湔婓");
        }catch(CreateException ex){
          throw new
            SQLException("id : "+id+"陔崝囮啖!");
        }catch(Exception ex){
        }
      }  public void deleteUser() throws SQLException{
        try{
          User user=userhome.findByPrimaryKey(id);
          user.remove();
        }catch(Exception ex){
          throw new
            SQLException("刉壺囮啖!");
        }
      }  public boolean isMember() throws Exception{
        try{
          User user=userhome.findByPrimaryKey(id);
          if(user.getPassword().equals(password)){
            name=user.getName();
            age=user.getAge();
            telephone=user.getTelephone();
            address=user.getAddress();
            return true;
          }
        }catch(ObjectNotFoundException notfoundex){
          return false;
        }catch(Exception ex){
          throw ex;
        }
        return false;
      }  public void setId(String id){
        this.id=id;
      }
      public String getId(){
        return this.id;
      }
      public void setPassword(String password){
        this.password=password;
      }
      public String getPassword(){
        return this.password;
      }
      public void setName(String name){
        this.name=name;
      }
      public String getName(){
        return this.name;
      }
      public void setAge(String age){
        this.age=age;
      }
      public String getAge(){
        return this.age;
      }
      public void setTelephone(String telephone){
        this.telephone=telephone;
      }
      public String getTelephone(){
        return this.telephone;
      }
      public void setAddress(String address){
        this.address=address;
      }
      public String getAddress(){
        return this.address;
      }
    }
      

  2.   

    在jsp中调用javabean中的insertUser 时,它并没有向数据库中新增一笔记录﹐返回password为null. 请高手指点!!我找了很久都不知道为什么,急死了....
      

  3.   

    gz帮你up吧,我也想知道,从上午等到现在了...
      

  4.   

    ps.executeUpdate();
        是不是错了,适宜是ps.execute();
      

  5.   

    ps.executeUpdate();
    也应该是可以的~~只是ps.execute();
    还多执行任何的SQL(如SELECT)密码生成应该没有问题的,不知道你的TABLE中的PASSWORD是不是允许NULL我想是应该允许
    不然会有SQLException的(废话~~)恩~~怎么不调试一下?
    关注中~~!!@!@
      

  6.   

    调用javabean中的insertUser 时,執行User user=userhome.create(id, name, age, telephone, address);
          錯誤如下:
     java.rmi.RemoteException:EJB Exception:;nested exception is:
        javax.ejb.EJBException:ejbCreate exception:null
    急死了,快快幫忙, 搞定就結貼.
      

  7.   

    ejb ejbcreate中返回不为password,为null,看看
      

  8.   

    User user=(User)userhome.create(id, name, age, telephone, address);
      

  9.   

    程序误应该没有什么问题,应该是发布或者配置的问题,
    JBuilder生成EJB时会自动生成一个TEST的Methods,
    发布完了试验一下是否成功了
      

  10.   

    wafer_w(流浪的风) 说的对,类型转换是肯定要加的。
      

  11.   

    tian, 我試了還是不對, 發布是成功了,配置就說不清有可能沒置好。
    TEST 也是一樣的錯誤.
      

  12.   

    你的
    getConnection()中
    是这样的
    Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.23.39:1521:sorder","test","test");注意你的con对象是新创建的,并不是你的全局con所以你的全局con是null...
    所以你在调用con.get****异常
    所以是null异常